Hey there, I’m trying to make a fire wall in my game move towards the right without any input at a constant speed in GDScript in the 2D workspace. It is not a solid object - the only collision would be with the player, which then triggers the killzone script. The problem is, I’ve been thinking and thinking and can’t think of a way for it to work! Would anyone be willing to help me?
I’m using Godot 4.3 and am relatively new to coding.
do you want the object to move based on physics with a velocity and experiencing collision and calculating context?
or do you just want it to move to a destination without regard to physics or collision?
For the former, you would need to convert it into an object that can experience physics, like a rigid or characterbody.
For the latter, you can just do a tween from its current position to its end position.
During its movement, your character or itself need to detect the other via area2d and trigger the killzone script
What is a Tween?
A tween is a simple animation that adjust a value of an object from current to destination. It can be a value that steadily increases or decreases, it can be a color, it can be its size (AKA: scale).
The full logic is written as such
var tween: Tween # we create an object of type tween
tween = create_tween() # we initialize the tween. it will now run instantly
tween.tween_property(object, "property", value, duration) # we set its tween property so it can change it over the set duration until it reaches the value.
This would depend on your exact game but a fairly easy way is to just update the wall and move it each frame useing somthing like
funs _dealt(Time)
%wall.global_possition.x += 1