Jump to content

Phaser apply velocity changes to multiple sprites at the same time


The_dude8080
 Share

Recommended Posts

Hey. I am using phaser arcade physics. I want to make many sprites acts as one. That means that when I press one of my cursor keys (that adds velocity) all of the sprites should be applied the same properties. I did that with a group that included all the sprites (they were about 100) and did a for each when clicked on a cursor to get each of the group children. However I think it was too slow because the sprites didn't actually move at the same (the code didn't seem to tweak fast enough). I can't add them to a "null" parent sprite because I don't want them to get fixed-in-place positions related to the parent. I want them to freely interact with each other as individual sprites but the movement should be applied to all of them when cursor keys are clicked. Any idea on how to do this? Thank you

Link to comment
Share on other sites

When you say "I think it was too slow" what does that mean? Setting the velocity on each sprite individually is what Phaser would do under the covers, there's not magic available to it that isn't also available to you.

If you set their velocities in a single function then all their velocities were set at the same time, full stop. Nothing can run in between when you set the velocity of one sprite and when you set another.

Link to comment
Share on other sites

1 hour ago, drhayes said:

When you say "I think it was too slow" what does that mean? Setting the velocity on each sprite individually is what Phaser would do under the covers, there's not magic available to it that isn't also available to you.

If you set their velocities in a single function then all their velocities were set at the same time, full stop. Nothing can run in between when you set the velocity of one sprite and when you set another.

Yeah you are right. Wasn't think clearly at the time. Related to this I am facing this problem...  Well when you change sprites velocity to big values and they collide in a small space they will start bouncing and getting bugged all over the place. One of the things I would like to be able to do is to make multiple sprites not overlap with each other like really rigid bodies even if they collide at really high speeds. Can you help me with this?

 

Link to comment
Share on other sites

Arcade physics isn't so great at the rigid body thing, especially around getting things to believably stack and not be weird about it. One thing you could try is calling the physics routines multiple times per update... but if things are moving at high speeds then they're gonna bounce in big ways.

I wish I could help more!

Link to comment
Share on other sites

21 minutes ago, drhayes said:

Arcade physics isn't so great at the rigid body thing, especially around getting things to believably stack and not be weird about it. One thing you could try is calling the physics routines multiple times per update... but if things are moving at high speeds then they're gonna bounce in big ways.

I wish I could help more!

I see. That already clarifies some things :) Thank you 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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