The Dangers of Mixing Movement Types in GameSalad
thebitmaster
PRO Posts: 75
GameSalad has a great built-in 2-D physical modeling engine. Sometime, though, I find myself wanting to do something “outside the engine”, for instance, manually moving an actor myself instead of letting the engine do it. There are times when this is definitely the Right Answer, but you have to be careful. Why?
Because collision detection does *strange* things when there’s a collision with actors you are moving manually.
I just had an instance where when my projectile hit my vending machine, it would dispense two items EVERY SINGLE TIME. I tried adding a time-delay after the initial collision before a second Spawn behavior would be fired, but it didn’t matter. Additionally, the second dispensed actor spawned was misreading its own location on the screen, despite the fact that it was being generated from exactly the same location as the first one. What was going on? I had no idea. I tried making the projectile destroy itself on initial impact. Still got two spawns. I tried several other ideas, it still happened.
Finally, I altered the projectile itself. Previously I had been manually handling its movement, because I was trying for a pseudo-3-D effect where it got bigger as it arced up, and smaller as it arced down. The change? I altered it to use GameSalad’s physics engine instead of moving it myself.
Viola, I got one item dispensed for each collision!
The lesson? Try to use the build-in engine whenever possible, and expect the unexpected, especially from collision detection, when you decide to move things on your own.
From my website:
http://scottmauer.wordpress.com/2011/11/17/the-dangers-of-mixing-movement-types-in-gamesalad/
Because collision detection does *strange* things when there’s a collision with actors you are moving manually.
I just had an instance where when my projectile hit my vending machine, it would dispense two items EVERY SINGLE TIME. I tried adding a time-delay after the initial collision before a second Spawn behavior would be fired, but it didn’t matter. Additionally, the second dispensed actor spawned was misreading its own location on the screen, despite the fact that it was being generated from exactly the same location as the first one. What was going on? I had no idea. I tried making the projectile destroy itself on initial impact. Still got two spawns. I tried several other ideas, it still happened.
Finally, I altered the projectile itself. Previously I had been manually handling its movement, because I was trying for a pseudo-3-D effect where it got bigger as it arced up, and smaller as it arced down. The change? I altered it to use GameSalad’s physics engine instead of moving it myself.
Viola, I got one item dispensed for each collision!
The lesson? Try to use the build-in engine whenever possible, and expect the unexpected, especially from collision detection, when you decide to move things on your own.
From my website:
http://scottmauer.wordpress.com/2011/11/17/the-dangers-of-mixing-movement-types-in-gamesalad/