Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | jacobb | |
Old Version | Published before Godot 3 was released. |
I’m trying to make an object go upwards when a key is pressed - this code doesn’t work:
extends Spatial
var flprop
func _ready():
flprop = get_node("flprop")
self.set_process(true)
func _process(delta):
if Input.is_action_pressed("drone_up"):
flprop.apply_impulse(Vector3(0, 0, 0), Vector3(0, 10, 0))
but if I move the flprop.apply_impulse()
line into the _ready
function, the object does have the force applied.
Apply a positioned impulse (which will be affected by the body mass
and shape). This is the equivalent of hitting a billiard ball with a
cue: a force that is applied once, and only once. Both the impulse and
the offset from the body origin are in global coordinates.
Maybe use flprop.apply_impulse(flprop.get_traslation(), Vector3(0, 10, 0))
?
genete | 2016-06-15 21:36