#How to apply basic 2D forwards momentum?

11 messages · Page 1 of 1 (latest)

onyx shard
#

for top-down tank controls, i want to apply or append a chosen momentum relative to the rotation of its node rotation. how do i do such a thing?

old pewter
onyx shard
#

i meant more like an Asteroids-like movement for a CharacterBody2D

#

i know there's self.rotate() to handle steering, i just don't know how to apply a force to a chosen direction without individually dealing with velocity.x and velocity.y individually

#

btw the editor tells me there's no apply_torque() or add_torque() in neither RigidBody or CharacterBody

onyx shard
#

..i figured it out

#

just invoke a rotation of a Vector2 and apply that to the speed you'll eventually use

#

so the code i made looks something like

Vector2(torque, 0).rotated(self.rotation)
old pewter
onyx shard
#

i'll play around with those at some point :3

#

but thank you for the help!