Tag Info

Hot answers tagged

4

This is entirely a matter of convention. (Since you didn't mention any particular tools.) But! If you are modeling in the same default orientation as your screen, which you say is right-handed, X-right, Y-up, and therefore Z-towards-you, then it would be natural to model your characters facing you, where forward is Z-positive. Which also implies your ...


3

You can use the OnBecameInvisible callback for that. Just implement something like: void OnBecameInvisible(){ // disable or destroy gameobject } The method will get called when the object isn't being rendered by any camera anymore. This also includes cameras from the Unity-Editor. So if you're running your game and have the Game and the Scene view ...


2

user1118321's answer will provide you the correct answer, though it is more general than necessary. Since we're dealing with a right triangle, the easiest solution is to use the definition of the tangent function: tan(α) = A / B Substituting half the height of the screen, the z coordinate of the camera, and half the vertical field of view gets us: ...


2

Check out the Law of Cosines. It allows you to calculate any side or angle in a triangle if you have the opposite 2 angles or sides. Or alternately, use the law of sines (described at the bottom of the above link). In your case, you know that vertical field of view is 45 degrees and that the base side you want is the height of the screen. You can think of ...


2

Iterating through the faces: faceNormal[i].dot(-worldViewVector) > 0.8 //(should actually be >0.9999) If you do an if/switch to apply a rotation to the cube(or camera): Just update and store a value indicating the front face at the same time. This actually works the same for non-snapping angles such as your scene view. In the orthogonal mode, the ...


1

Hello I suggest you use Raycasting to test if the camera is directly pointing to the light source. The ray will go from the camera into the front vector direction, Once you get the RaycastHit, you can check the name, the tag or even use Layer Mask to selectively ignore colliders. If you want to apply the effect even when the camera is not pointing directly ...


1

one solution is to remove the directional light and relay only on other lights; then set ambient light near to dark.


1

Just make the main camera a child of the player object in the hierarchy, then move it to where you want it in the scene view with the translate/rotate tools. Don't make it overly complicated with code. Or apply the same control scripts and colliders to the camera as to the player object.


1

You need to clamp the vertical rotation. I don't know off the top of my head the simplest way to adjust that code, but it'll just involve changing a couple lines around the transform.RotateAround() stuff, to use Mathf.Clamp() for the angle around the x-axis. I think you just need to put in y = Mathf.Clamp(y, -180, 180); right after incrementing y. This way ...


1

The key is to analyze how an actual camera would work. If you're pointing it toward, say, a wall in front of you, then you point it toward the ceiling, and then keep turning it "up" you will find that the ground will actually start to come into view from the top. It seems odd at first - but the actual camera configuration you have is already "correct" IMO. ...


1

Update runs once per frame. Using while in the update script like that, in English reads like this: "Once for this frame, while the mouse button was held down for this frame, move the camera and stuff". The reason why this does not work well is because, the mouse will be in a 'down' state until the next frame, and it wont go onto the next frame until the ...



Only top voted, non community-wiki answers of a minimum length are eligible