|
|
|
|
Reply From: |
Zylann |
I looked at KinematicBody.move_to
… and it’s not explained very well IMO.
It doesn’t do what you think it does, in fact, it calls move()
with a motion equal to the distance to the position you give it:
// Engine code
Vector2 KinematicBody2D::move_to(const Vector2& p_position) {
return move(p_position-get_global_position());
}
So it actually is a teleport, unlike the doc says. It’s just that it will stop if it encounters a collision on its way. Speed makes no sense here.
On the other hand, using move
you can specifiy a direction, as explained in my answer move an object / sprite forever at its current angle / rotation ? - Archive - Godot Forum
By doing this:
move(direction_vector * (speed * delta))
When it says “not a teleport” is because can’t go through obstacles (call Scotty and you will stop outside the hull of the Enterprise), like a set_pos
but aware of collisions.
Useful for grid movement and, maybe, some extreme speed-like motions.
I see it as a teleport because it doesn’t run over time, so it’s not actual motion, it’s a “clever” set_pos() ^^
I don’t see how it’s useful for grid movement? With colliders setup as a grid you would still need to snap
Zylann | 2017-02-19 18:32
We agree on the set_pos, maybe docs should explain that way too.
And the snap, sure, depends on the shapes and how snappy needs to be.
thx… it works… but i founded a way that we can set an object sprite to another object position… so the angle wont change forever… its a stupid way to do it… but atleast it works … haha
AnotherUserz 1 | 2017-02-24 10:01