Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | HarryCourt | |
Old Version | Published before Godot 3 was released. |
I don’t understand why it isn’t moving, it is in the correct child.
extends KinematicBody2D
export var MOTION_SPEED = 140
var RayNode
func _ready():
set_fixed_process(true)
RayNode = get_node("RayCast2D")
func _fixed_process(delta):
var motion = Vector2()
if(Input.action_press("ui_up")):
motion += Vector2(0, -1)
RayNode.set_rotd(100)
if(Input.action_press("ui_right")):
motion += Vector2(1, 0)
RayNode.set_rotd(100)
if(Input.action_press("ui_left")):
motion += Vector2(-1, 0)
RayNode.set_rotd(100)
if(Input.action_press("ui_down")):
motion += Vector2(0, 1)
RayNode.set_rotd(100)
motion = motion.normalized()+MOTION_SPEED*delta
move(motion)
Is your indenting correct there, because you have the motion only happening if the down arrow is pressed?
Also, you probably want to use Input.is_action_pressed()
here.
kidscancode | 2017-07-21 15:51
motion.normalized()+MOTION_SPEED*delta
should probably be
motion.normalized()*MOTION_SPEED*delta
markopolo | 2017-08-16 16:28