About 'Better CubeDude Movement'!

In this video (objectives)…

1 Animate CubeDude 2 Have CubeDude face forwards 3 Make sure diagonal movement isn't faster than cardinal movement

After watching (learning outcomes)…

Make CubeDude move in a more natural and predictable way

(Unique Video Reference: 8_CK_GDT)

We would love to know…

  • What you found good about this lecture?
  • What we could do better?

Remember that you can reply to this topic, or create a new topic. The easiest way to create a new topic is to follow the link in Resources. That way the topic will…

  • Be in the correct forum (for the course).
  • Be in the right sub-forum (for the section)
  • Have the correct lecture tag.

Enjoy your stay in our thriving community!

@Yann_Burrett
I did like the lecture! Using a little vector math and playing animations to make the game look nice in a simple and effective way is just fun :slight_smile:

There is one thing that bugs me though:
I think the vector math in the face_forward() function is a little off and you can see that at around 10:30 - 10:50 minutes in the video:
The player rotates around the world origin!
Why is that? You assume that look_at() works in local space, but it doesn’t! look_at() uses global space.
So what do we need to change? We need to add global_transform.origin to the Vector, so we look from where we are to the place where we are going:

func face_forward():
	if motion.x != 0 or motion.z != 0:
		look_at(global_transform.origin + Vector3(-motion.x, 0, -motion.z), UP)

Now, why does the player still look in the correct direction in the video after you multiply the normalized vector by speed? Making a vector longer or shorter doesn’t change its direction at all! Because we now look at a point that is 10 units away from the origin, which is a good enough approximation of the correct direction in our small pitch to not see the problem. Especially when the player is animated as lively as cubedude :slight_smile:

If I’m wrong about this and someone knows why, please tell!

Again, having fun with the course, great work and thank you @Yann_Burrett!

Privacy & Terms