Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | kamilko |
I have such code:
extends KinematicBody2D
var new_position = Vector2.ZERO
var speed = 600
var velocity = Vector2.ZERO
func _ready():
randomize()
new_position = Vector2(rand_range(50, 950), rand_range(50, 550))
func _physics_process(delta):
velocity = position.direction_to(new_position) * speed
print(velocity)
if position.distance_to(new_position) > 2:
velocity = move_and_slide(velocity)
func _on_MoveTimer_timeout():
randomize()
new_position = Vector2(rand_range(50, 950), rand_range(50, 550))
Example output of print:
(-473.734711, 368.205627)
(-473.73468, 368.205627)
(-473.734711, 368.205719)
(-473.73468, 368.205688)
(-473.73468, 368.205719)
(-473.73468, 368.205719)
(-473.734589, 368.205902)
(473.733551, -368.207153)
(-473.734589, 368.205902)
(473.733551, -368.207153)
(-473.734589, 368.205902)
(473.733551, -368.207153)
...
(-546.8479, 246.895569)
(-546.847839, 246.895569)
(-546.8479, 246.895569)
(-546.847839, 246.895569)
(-546.8479, 246.895554)
(-546.8479, 246.895554)
(-546.847839, 246.895538)
(-546.8479, 246.895538)
(-546.8479, 246.895523)
(-546.8479, 246.895493)
Is this some bug in Godot?
This could be unnoticed if sprite of this object had odd number of pixels in every direction, however I have even count of pixels and some rotating animation and final effect is like two interlaced object flipping between places.