The Dangers of Mixing Movement Types in GameSalad

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.

This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s