All Questions

Community

ltsdw

Why do we need to change the calculations for the rocket on this one?

On the Making the turret aim and rotate we could test the rockets and they was getting launched correctly, without using the cannon.global_position, but not on this one, why is that?



Hehe, btw, not related to my question, I was so confused since the start of this course about the vectors, transforms, positions, rotations and so on... it was probably due to a lack of knowledge in a lot of linear algebra concepts that I didn't learn in school, and learned this week.

So I decided to ace the Vector Math and Matrices and transforms from the Godot engine documentation, learn the math behind it, everything that was mentioned there, and now I feel a lot more confident about it. :D

  • Nathan Lovato replied
    Solution
    On the Making the turret aim and rotate we could test the rockets and they was getting launched correctly, without using the cannon.global_position, but not on this one, why is that?

    Itś because we assigned the global transform

    rocket.global_transform = cannon.global_transform

    This is equivalent to assigning the global position, rotation, and scale at once. Itś equivalent to the following code:

    rocket.rotation = cannon.rotation
    rocket.global_position = cannon.global_position
    rocket.scale = cannon.scale

    The difference here is that each rocket needs a different rotation, because the targets are in different places, so we can´t assign the cannon's transform. Assigning the transform it would cause all rockets to have the same orientation as the canon. So instead, we only assign the canon's position and rotate each rocket based on its target's position.

  • Nathan Lovato replied

    I took note to work on some series or guides dedicated to vectors and matrices. The ones from the official documentation are pretty good, I recommend them, but I think we can make something a bit more accessible and interactive still.

  • ltsdw replied

    I took note to work on some series or guides dedicated to vectors and matrices. The ones from the official documentation are pretty good, I recommend them, but I think we can make something a bit more accessible and interactive still.

    wow that would be marvelous.

    and I agree with you at least from what I saw so far about the documentation taught me so much, dot product, cross product, angle calculations (angle(), angle_to(), angle_to_point()), and so on, I was so happy to finally understand what was happening.