You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
extendsRigidBody2Dfunc_physics_process(delta):
varmovement_vec=Vector2(1, -1) # not normalized, will result in movement over a longer distanceposition+=movement_vec
Node 2 script - moving at normal speed diagonally
extendsRigidBody2Dfunc_physics_process(delta):
varmovement_vec=Vector2(1, -1)
movement_vec=movement_vec.normalized() # normalized, will match movement distance with Nodes moving in a single directionposition+=movement_vec
Node 3 script - moving only upwards
extendsRigidBody2Dfunc_physics_process(delta):
varmovement_vectormovement_vector=Vector2(0, -1) # already is normalizedposition+=movement_vector
Node 4 script - moving only rightwards
extendsRigidBody2Dfunc_physics_process(delta):
varmovement_vectormovement_vector=Vector2(1, 0) # already is normalized position+=movement_vector
Diagonal movement with direction_to is normalized - test
Node 1 script - node moving diagonally
extendsRigidBody2D@onreadyvartarget=Vector2(position.x+316, position.y-316)varspeed=0.5func_physics_process(delta):
varvelocity=position.direction_to(target) *speed# direction vector * speed is called velocityposition+=velocity
Node 2 script - node moving rightwards
extendsRigidBody2D@onreadyvartarget=Vector2(position.x+316, position.y)varspeed=0.5func_physics_process(delta):
vardirection=position.direction_to(target)
varvelocity=direction.normalized() *speed# direction vector * speed is called velocityposition+=velocity