New answers tagged

0

First, construct a quaternion or rotation matrix from the parent's rotation angles. Multiply your local position offset vector by this matrix or quaternion to get the offset in world space. Lastly, add the parent position to get the child's absolute position in world space. (You can fold this into the previous step if you use a 4x4 homogeneous matrix with ...


0

You started with a 3x3 grid/mesh of unit 240px positioning the dot in its center (0,0). Next you move the dot 1 unit (240, 0) to the left which is the center of the first column. By adding a column to the right the mesh center point the mesh is now 4 units wide moving the dot half a unit (120px) relative to the new center which equals to 240px + 120px = ...


1

Did you want this? var localVelocity = transform.InverseTransformDirection(worldVelocity); or var localVelocity = Quaternion.Inverse(orientation) * worldVelocity; This gives you a vector in the local coordinate frame of the transform/quaternion, where the z component is the forward velocity, the x component is the sideways velocity, and the y component is ...


0

Usually for rotations you use slerp. https://docs.unity3d.com/ScriptReference/Vector3.Slerp.html A basic rotation script is something along the lines: private float _timeRotation = 0f; private float _speed = 1f; private Transform _fromPos; private Transform _toPos; private bool _isRotating = false; void Update() { if (...


0

The dot product should tell you if the camera is looking roughly at the enemy or away from it. You have it in comments: var facing_target = direction_facing.dot(direction_to_enemy) Now, if that is less than 0, it means the camera is looking away from the enemy. In that case, take screen_pos and scale it, such that when you clamp it it will be on the edge of ...


Top 50 recent answers are included