Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

make object move towards player p5js

this.rotation = atan2(player.y - this.y, player.x - this.y);
this.speed = 2.5;

this.x += cos(this.rotation) * this.speed;
this.y += sin(this.rotation) * this.speed;
Source by gamedev.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #object #move #player
ADD COMMENT
Topic
Name
2+5 =