.rotation and multiple sprites

SameSame Posts: 12Member

I'm learning Godot and as a part of that, I'm coding a tank segmented into two parts: the body sprite, and the turret sprite, both are attached to a kinematicBody node that contains a script that moves the tank and triggers the shooting. The turret sprite contains a short script to rotate itself after the mouse.

Now here's the issue. As I rotate the tank body the bullet fired from the turret flies away at disparate angles wholly unrelated to the way the barrel is facing.

Now my theory is that since the bullets angle is derived from the relative position of the tank's rotation but the bullet is placed on the main node it receives a strange angle.

How do I resolve this? I've done a bunch of looking, maybe I'm tired or blind, but I can't seem to find anything.


Tags :

Comments

  • TwistedTwiglegTwistedTwigleg Posts: 2,641Admin

    Welcome to the forums @Same!

    How are you spawning the bullets? Maybe they are being attached to the tank itself, which causes them to rotate funny when the tank rotates. Also, have you tried using global_rotation instead of rotation when spawning?

  • SameSame Posts: 12Member

    Thank you very much,

    global_rotation seems to have done the trick! I'm still familiarizing myself with the various predefined variables and methods, I'm not used to them, thanks a lot!

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file