0 votes

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!

asked Jan 16, 2019 in Engine by Rob1980 (70 points)

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?

Doesn’t matter, I found the mistake: pratically, I had the wrong script! I'm going to hide immediately! :-(

no need to hide! just post your own answer

1 Answer

0 votes
Best answer

Doesn’t matter, I found the mistake: pratically, I had the wrong script!
Shame on me! :-(

answered Jan 17, 2019 by Rob1980 (70 points)
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 How to use this Q&A? before posting your first questions.