Jump to content

Changing speed but not direction?


Mike018
 Share

Recommended Posts

I have an object that bounces around in all directions via arcade physics and every 10 seconds, it changes speed. But every time it changes speed, it will not continue in it's current path, but change directions based on the initial velocity. How can I increase the speed while maintaining it's current path?

 

var speedChange = 50;

this.blade1.body.velocity.x = this.enemySpeed + speedChange;
this.blade1.body.velocity.y = this.enemySpeed + speedChange;

this.enemySpeed += speedChange;
Link to comment
Share on other sites

1 hour ago, VitaZheltyakov said:

	this.body.velocity.x = Math.cos(this.rotation) * this.speed_new;
	this.body.velocity.y = Math.sin(this.rotation) * this.speed_new;

or


this.physics.velocityFromRotation(this.rotation, this.speed_new, this.body.velocity);

 

Both of those seem to not be working. Once the speed changes, the objects will lose their y velocity and just move left and right. Also, the x velocity will not continue in the same direction all the time.

Link to comment
Share on other sites

8 hours ago, Mike018 said:

Both of those seem to not be working. Once the speed changes, the objects will lose their y velocity and just move left and right. Also, the x velocity will not continue in the same direction all the time.

You can not test my code?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...