Shooting Two Projectiles at the Same Time

I had a discussion similar to this a while back, but it was never fully answered for me, how do I get something to shoot two different projectiles at the same time? The coding seems to go in order, so one projectile gets shot just before the other one, is there a way to make it so they both get shot at the EXACT same time? I tried putting them in groups too, but that didn't work.

Having trouble with your game? Sounds like a personal problem.

Best Answer

  • tatiangtatiang Posts: 11,949
    Accepted Answer
    Try an adhoc build and see what happens. Everything's relative... it's possible to see lag with a couple of actors with long, complex rules or with many, many actors with moderate rules.

    Try to simplify your rules if you can. Remove constrains and timers if possible.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Answers

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I don't know that there's a way to do it at the exact same time. One spawn behavior is going to run a split second before the other. Why is it important that they be exactly synced?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ADSentertainmentADSentertainment Member Posts: 397
    I don't know that there's a way to do it at the exact same time. One spawn behavior is going to run a split second before the other. Why is it important that they be exactly synced?
    Well like, I have a ship that has two twin blasters, and when you press space (or the fire button if you're on a touch screen) they'll shoot at two separate times. It's just not as aesthetically pleasing as it would be if you had them shoot at the same time, lemme show you what I mean
    What I have: photo ScreenShot2012-12-25at100722AM.png
    What I want: photo ScreenShot2012-12-25at100217AM.png

    It just looks a lot nicer and would make more sense if they were to be shoot at the same time.

    Having trouble with your game? Sounds like a personal problem.

  • BBEnkBBEnk Member Posts: 1,764
    The spawn behaviors should fire on the same frame. I did a quick test and the were spawning at the same time I even tracked the X.pos and it was the same as they moved across screen and no matter how many I fired they were in sync.
  • ADSentertainmentADSentertainment Member Posts: 397
    The spawn behaviors should fire on the same frame. I did a quick test and the were spawning at the same time I even tracked the X.pos and it was the same as they moved across screen and no matter how many I fired they were in sync.
    Hmmm, that's weird. Maybe it's because of the amount of actors in my scene or something? That's honestly the only other thing I can think of

    Having trouble with your game? Sounds like a personal problem.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Yeah, there shouldn't be ANY visible difference in their location. If anything, I would expect one to spawn at 0.001 seconds after the condition and one to spawn at 0.0015 seconds (those are just estimates but you get the idea).

    How are you spawning the two projectiles? Try a simple rule (e.g. When mouse button is down) with just two spawn behaviors back-to-back. Does this visible issue you posted still happen?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ADSentertainmentADSentertainment Member Posts: 397
    Yeah, there shouldn't be ANY visible difference in their location. If anything, I would expect one to spawn at 0.001 seconds after the condition and one to spawn at 0.0015 seconds (those are just estimates but you get the idea).

    How are you spawning the two projectiles? Try a simple rule (e.g. When mouse button is down) with just two spawn behaviors back-to-back. Does this visible issue you posted still happen?
    I did that, but it didn't change anything. However, I made a room and removed almost every actor except the ship, and they both shot at the exact same time, so I think it's because of the amount of actors in the scene. Would this only happen on the preview, or would it carry on to the .app file? I know that the preview has some problems with it, like small delays and such, so could that be the problem?

    Having trouble with your game? Sounds like a personal problem.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    I am assuming that GameSalad is running at 60 frames a second -- since LuaJIT's event frame is set up to do so. That means that (theoretically) the smallest time increment in which to fire anything would be 0.0167 seconds. The next instruction would happen .0167 seconds after that, and so on.

    So.... if both bullets are spawning one after the other, from the same actor, the time difference shouldn't be perceptible.
  • ADSentertainmentADSentertainment Member Posts: 397
    Try an adhoc build and see what happens. Everything's relative... it's possible to see lag with a couple of actors with long, complex rules or with many, many actors with moderate rules.

    Try to simplify your rules if you can. Remove constrains and timers if possible.
    I'll try that and see if the problem carries on to it, thanks!

    Having trouble with your game? Sounds like a personal problem.

  • SocksSocks London, UK.Member Posts: 12,822
    Works fine for me, I'm firing two or three bullets at the same time at they keep perfect (pixel perfect) sync . . . .


Sign In or Register to comment.