So in my game, I need to be able to detect which direction the player moves his camera in(right/left,up/down) However, I couldn't find a property of Camera that is the angle in which it is pointing at, so I couldn't figure out how to detect if the player was moving his camera right or left. Any way to do that?
You can access the current rotation of the camera by utilizing the Camera.CFrame property. In terms of checking if the camera is moving right or left, I would recommend reading into how CFrame angles function.
Related
I have a problem with freezing rotation in z axis. There is an airplane and a cinemachine free look camera is attached to it. When the plane rotates along the Z axis, the camera rotates with it. Is it possible to somehow block only one axis of rotation in cenimachine camera?
Need Change the binding mode to Lock To Target No Roll
Switch to Transposer>World Space. Because we have a problem, if the cinemachine is a child of the object, the rotation will happen, according to the orientation of the Z axis. I had the same problem. Mixing object rotation' (either for a simple movement or some rotation command), which is attached to the cinemachine camera, doesn't seem to be a good choice.
I have simulated a rotating cube filled with particles by moving the gravity vector rather than changing all of the geometry. I want to use the ParaView animation tools to rotate the camera to keep the gravity vector pointing down so it all looks right. When moving the camera (not animations) I would use the rotate 90 degrees tools.
How would I achieve this effect for an animation?
EDIT:
I have done it using a video editor as an extra step after ParaView, this is the effect I am going for: https://youtu.be/rym2fdKkPps
You cannot animate GUI button usage with animation. However you can animate camera position and orientation as finely as you want.
Try adding a camera track to the animation track of type "Interpolate Camera Location".
Add the two positions you want and set the time to be very close.
I'm having an issue where my character is facing 90 degrees away from the (first person) camera. So when I move the character, the model is turned 90 degrees to the right instead of facing forward. (Pic 1)
Since the camera is a child of the player, if I rotate the character -90 degrees, the camera rotates with it. If I rotate my camera back 90 degrees, the controls get messed up (the W to go forward becomes W to go right, etc.) (Pic 2)
Is there anything I can do to either change the default rotation of the
For reference, I am using this FP Controller torah horse(.)com(/)First-Person-Drifter-Controller-for-Unity3d-1 (that uses a cylinder, so doesn't have the same rotation issue)
I'd advise you to put a script on the Camera instead of making it a child of the player. This gives you more freedom in how the Camera behaves.
Actually, looking at your pictures again... Why not just set the Camera behind the player correctly, instead of rotating the player. When you have the Camera as s child it will be responsive to the parents transform, but it wont mimic. It will follow with the same offset as it starts with. So instead of rotating the player, which messes up the controls, simply put the Camera where you want it from the start.
I'm making a fps game and I want my character's arms to rotate up and down depending where the cursor/camera is pointing at. The character already rotates when I turn left or right. Hopefully someone can answer my question. I'm new to Unity and I'm still learning how to code in C#.
For top and bottom rotation, create an animation for top aim, eye level aim and feet aim. send the value of your rotation to animator controller and animate according to it.
I am working in Unity3D and I was wondering how I would rotate a cube based on the angle between the cube and the mouse position. With that I don't mean the mouse position in world space but in pixels.
Here are some pages that'll lead you to your answer:
Input.mousePosition This also includes an example of how to turn screen coordinates into a ray in world coordinates. If you know how far away from the camera you want your point, check out ScreenToWorldPoint for a point instead of a ray.
transform.Rotate To perform a rotation.
The rest of your question is kinda vague--rotating "based on" the angle between cube and mouse position could mean a lot of things. You shouldn't need much more information than this though!