The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

trying it using but object is moving diagonal (down-right)

var tween = getnode("Tween")
func _physics
process(delta):
myPos = self.position
destination = myPos + Vector2(0,0.1)
tween.interpolate
property(self,"linearvelocity",myPos,destination,1,Tween.TRANSLINEAR,Tween.EASEINOUT)
tween.start()
pass

Godot version 3.4
in Engine by (37 points)

1 Answer

+1 vote

Linear velocity is a Vector by which RigidBody moves. It describes the change of positions, a vector of difference between position now and position later. Thus it cannot be tweened with a global position vectors, this would give ridicolous results.

You need to rethink what is it You really want to interpolate. Direction of moving object ? Speed ?
The way your code looks it seems like You want to directly tween globalposition of the body. This is not advised, collisions won't be properly reported that way. Instead interpolate speed. Take direction to your target before tweening ( object position minus target position ), tween custom variable speed from 0 to desired number and in process() applyimpulse() using your normalized direction * this speed.

by (8,188 points)

Sorry, it works with
tween.interpolateproperty(self,"linearvelocity",null,Vector2(100,0),1,Tween.TRANSLINEAR,Tween.EASEIN_OUT)

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.