godotjs/javascript

position.x is not mutable and wrong class on godot.register_property crashes godot

Closed this issue · 2 comments

export default class Player extends godot.KinematicBody2D {
constructor() {
super();
this.direction = new godot.Vector2(1, 0);
}
_ready() {
}
_process(delta) {
this.position.x += this.direction.x; //does nothing. Same if I use a hard-coded value
}
}
godot.register_property(Player, 'direction', new godot.Vector2(1, 0));

godot.register_property(player, 'direction', new godot.Vector2(1, 0)); //crashes godot instead of an error message

you have to set this.position to take effect.
this.position+=this.direction should work

Added this to gotchas