0

My arrow(rigidbody2d) doesn't point correctly.

So i tried velocity.arngle() to rotate my arrow but didn't work. (Rigidbody2d) And i also tried offsetting the center of mass but didn't do a thing till it contacted something

Aaron
  • 1

1 Answers1

1

Since RigidBody2D is a subclass of Node2D, you could use one of these methods and properties to set the rotation explicitly:

func _ready():
    rotation = 1 * PI        # Set angle in radians
    rotation_degrees = 180   # Set angle in degrees
    rotate(-0.5 * PI)        # Adds the inputted angle to the current angle   

Although, the point of using a RigidBody2D is to have access to proper physics simulations and control movement via impulses and torque. Here are a few of the methods and properties to choose from:

func _ready():
    angular_velocity = 20     # Sets per second rotation in radians
    apply_torque_impulse(20)  # For single impacts

There are actually many more ways to affect a body's rotation than what I showed above. They're all in the Godot docs if you need them:

https://docs.godotengine.org/en/stable/classes/class_rigidbody2d.html

taennan
  • 61
  • 2