A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

# Tag Info

7

The Problem: Your eyes default rotation makes them look to the negative X axis. However, Transform.LookAt() rotates the transform, so that the Transform.forward looks at the target. The Transform.forward always looks to the positive Z axis. (All directions in local space). Solution 1: Rotate the texture or mesh, so that the eye's default look direction is ...

5

You can check simple ahead/behind relationships using the dot product: Vector3 displacement = B.transform.position - A.transform.position; float dot = Vector3.Dot(displacement, A.transform.forward); If dot is greater than zero, then B is ahead of A along A's forward vector. (The arrow from A to B has a component in the same direction as A's forward) If ...

3

The dot product between two unit vectors is: +1 when the vectors are pointing in the same direction 0 when the vectors are perpendicular -1 when the vectors are pointing in opposite directions So, we can get this value just by normalizing our two direction vectors and dotting them, and then massaging the output into the 0-1 range. In Unity-style syntax it ...

2

First, if you don't always want every projectile to move up, you should make the shot direction a variable: public class Projectile : MonoBehaviour { public Vector2 direction; public float speed; void Update() { transform.Translate(direction * speed * Time.deltaTime); } } Then you can make a firing method to spawn a projectile ...

2

A few rules of thumb around this, if the calculation only needs to be done once and applies to the entire object, then you will get best bang for buck calculating it prior to loading onto the GPU. IF though the calculation does change then you also need to consider where in the GPU pipeline it should be calculated. For instance, if you can calculate the ...

2

This is an old question but to put in to less technical terms, a Vector3 is a "container" for 3 float values - x,y,z. You can compare individual values, such as comparing the x values of two Vector3s, because they are just numbers. However, an entire Vector3 cannot be compared to another Vector3 because there isn't a single value that can be used to ...

1

Did you try something like this? childToTarget = targetPosition - child.position; childToTarget.y = 0; parent.position+= childToTarget;

1

I managed to solve collisions problem by splitting the collision handling into horizontal and vertical components, one at a time. The implemented idea is: Move player on horizontal axis. Check for collisions. Solve collision on horizontal axis. Move player on vertical axis. Check for collisions. Solve collisions on vertical axis. This system does not ...

1

New Answer Since you have two vectors to begin with, instead of two quaternions, Find the quaternion representing the rotation from one vector to another. Then you can take a copy of the current rotation quaternion, and multiply it with the quaternion you got from the vectors, which gives you the final rotation quaternion. You can then lerp from your copy ...

1

"How to change the up vector of something in Unreal ?" The answer is simple - to change the upvector you simply need to change the object's rotation. To make your upvector to point to something - you can use innate function of FMath especially take a look at: MakeRotFromXZ family of functions. docs

1

At the beginning of your game you could create a list of Steps (it would contain either the transforms or the colliders of all the steps of the scene). Every time the player presses down, you run through your list of Steps and try to find the closest one (using Vector3.Distance between player position and step position, it should be easy to determine the ...

1

To inverse the spawn point and other useful methods: // renamed double Vector2::AngleRadOther(Vector2 other) { return atan2(y - other->y, x - other->x); } // renamed double Vector2::AngleDegOther(Vector2* other) { return radiansToDegrees(AngleRadOther(other)); } double Vector2::AngleRad() { return atan2(y, x); } double Vector2::AngleDeg(...

1

It turns out I was probably overthinking this quite a lot. The solution in the end was to just calculate the rotated position of the object by rotating their current position Vec2 by the inverse of the camera rotation. I could then sort by this rotated Y value.

1

I'm not entirely sure, but this sounds like you still have your animation preview toggled on while trying to edit values. If this is the case, you might also notice that the input field for the value you are trying to edit has a blue background. Click the preview button to toggle it. Make sure that when you are trying to edit the values to a keyframe, the ...

1

I highly doubt that the artists designed every vests for every body shape as it would be a tremendous amount of work I am pretty sure that this is exactly what they did. There aren't actually that many body shapes in the game. It's not much work because the torsos of the characters in Rimworld have no animation at all and the graphic style is very ...

1

So, you want to get a forward vector parallel to the ground plane relative to the camera's rotation, from what I can get. The solution is as simple as using Vector3.Cross(Vector a, Vector b), it is not commutative, so you'll have to give the vectors in the correct order. What the cross product gives you, is a vector C perpendicular to 2 vectors A and B. So, ...

1

Welcome to the joy of the cross product! The cross product of two 3D vectors gives a third vector that's perpendicular to both the inputs: Vector3 c = Vector3.Cross(a, b); In a left-handed coordinate system like Unity's, you can make a thumbs-up pose with your left hand, and hold it so that the flat of your hand points in the direction a and your fingers ...

1

You're recreating the velocity vector every frame as DMGregory pointed out already. The newly created vector likely has a value of 0 on all axis so multiplying it with 0.3 results in a velocity of 0. The other case "ctrl.action().thrust == 1" only works because you are always adding a value first. Just move the velocity-vector object out of the function ...

1

Imperial's answer works fine if you are in a game engine that has the normalise() function, but if you are doing something a bit more homebrew, the actual math works like this: Since both points are an object with a known X, Y, and radius value, you can use your basic slope formula tells us Slope=(Y2-Y1)/(X2-X1) We also know that both objects will follow ...

1

This should work: For each point of the line: point = point + ((otherPoint - point).normalise() * radiusToSubtract) Explanation: First we get the direction from the point we're moving to the other point (otherPoint - point).normalise() Then we multiply that unit vector by the amount you want to budge the point toward the other point * radiusToSubtract)...

1

Just change the order of your operations, and make sure you use 2d vector values for everything (force, acceleration, velocity, position.) Your clamping should be done at the last step, after you have accumulated all the forces, calculated the acceleration, applied the acceleration. accumulate all forces acceleration = force / mass velocity += acceleration ...

1

If I understood your question correctly, the problem is that the directional arrows in the scene view aren't rotating with your character. One problem that I can think of off the top of my head is that your coordinate system for the translation arrows is set to global. There's a button at the top of the scene tab that's split in half, clicking on the left ...

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