godotjs / javascript

Javascript binding for godotengine
https://godotjs.github.io/
MIT License
980 stars 82 forks source link

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

Closed YasribProyas closed 1 month ago

YasribProyas commented 2 years ago

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

Geequlim commented 2 years ago

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

nmerget commented 1 month ago

Added this to gotchas