How can I move the object smoother?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SDGN16

the player seems to teleport as my object goes left and right. How can I move the object more smoothly when it is moving?

extends KinematicBody
var v = Vector3()
func _physics_process(delta):
	v = Vector3()
	if Input.is_action_just_pressed("a"):
		v += transform.basis.x
	if Input.is_action_just_pressed("d"):
		v -= transform.basis.x
	move_and_collide(v * 5)
:bust_in_silhouette: Reply From: Ertain

Have you tried factoring in delta? That is, in this part of the code?

move_and_collide(v * 5 * delta)

When you do as you said, the object does not go 5 units. do you have any other ideas?

SDGN16 | 2021-03-06 21:26

That’s just how delta time works, try increasing the speed so that it goes at what looks to you is 5 units per frame

For example move_and_collide(v * 150 * delta)

And no im not exagerating with 150, delta is usually a very small value so you use a relatively high speed value

Kurotsuki | 2021-03-10 14:33