All Questions

Community

S
Lim Shan Kuo

No movement on the Player

A fresh installation of Godot 3.1.1 (Windows). Working on the lesson "Starting to code character movement". Only 7 lines of the example script code, the player sprite is frozen?

extends KinematicBody2D

class_name Actor

func _physics_process(delta):

var velocity = Vector2(300,0)

move_and_slide(velocity)

Run without errors but some warning of deltas arguments is never used and move_and_slide() return value is never used. Is there any that I missed.

  • Nathan Lovato replied
    Solution

    Which node did you attach the script to? It should move with that code. The warnings you're getting are unrelated as their message indicates: you're not using some values that you don't need at this stage, that's completely fine.

  • S
    Lim Shan Kuo replied

    you have given me a hint that which node should be attached to and its not attached to the Player (KinematicBody2D node). Problem solved, sprite can move along the X horizon.

  • H
    BooksRCool replied

    I had the same problem with the block being frozen, until I deleted the code that I had in the Actor script. Then I copied the lines of code above on this page. After I pasted it in the Actor script. I had to tab over the last two lines of code. Then with the Player selected under the Scene Tab, I went over to the Inspector Tab and in the script drop-down menu, I loaded the Player Script and it worked. Not sure why...