Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Rob1980 |
Hi everyone! Today I have a problem with the movement of a KinematicBody2D.
This is the structure of my object:
- KinematicBody2D
– Sprite
– CollisionShape2D
And this is my script:
extends KinematicBody2D
var vel = Vector2()
var rotation_speed
func _ready():
randomize()
set_physics_process(true)
vel = Vector2(rand_range(30, 100), 0).rotated(rand_range(0, 2*PI))
rotation_speed = rand_range(-1.5, 1.5)
func _physics_process(delta):
rotation += rotation_speed * delta
move_and_collide(vel * delta)
Unfortunately, however, nothing happens! How can I solve it? Thank you!
Well, i’ve tested the very same code you posted, and works on my pc. Could you share the project to see it in depth?
p7f | 2019-01-16 11:33
Doesn’t matter, I found the mistake: pratically, I had the wrong script! I’m going to hide immediately!
Rob1980 | 2019-01-17 00:49
no need to hide! just post your own answer
p7f | 2019-01-17 00:50