0 votes

so yea.. i wanna move my first object to the second object.. but how do i set the speed ?

in Engine by (19 points)

I explained this in your previous question :)

1 Answer

0 votes

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 https://godotengine.org/qa/12544/move-an-object-sprite-forever-at-its-current-angle-rotation

By doing this:

move(direction_vector * (speed * delta))
by (29,090 points)

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 :p

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.