Game Development Community

Colliding with "powerups".

by Shane · in Torque Game Builder · 10/05/2009 (5:11 pm) · 8 replies

I am making this game that has various powerups. I set up their send/receive collisions and when the ship hits the powerups bingo they get the item in question. Problem is when the ship hits the power up it like stops its forward momentum for a while. Why is this? The ship uses the asteroids movement behavior that uses the set impulsePolar, yet when it runs into a powerup , bam it stops it dead in its tracks. The powerup otherwise behaves just great. how do I stop the getting of an item from stopping the ships forward speed. '

The best I can figure is to have either a trigger that the powerups are attached to, and thats how one knows you picked up the powerup by hitting the trigger (Therby removing lal collision checks that part of the powerup sprite). Though this sounds like the wrong way and I would have to mount a special trigger fore very pickup item in the game.

I cannot set the collisions off cause then the game wouldn't know if they hit a power up or not. So what other choices do I have? This seems very straightforward to say (yes detect when its hit but dont stop these hip dead in its tracks)..any ideas? or should I just go for the trigger item mounted to the pickup item.

Thanks,
Shane




#1
10/05/2009 (5:39 pm)
I think Patrick would say that you should attach a trigger to the pickup item.

It wouldn't be too hard, either. Just make derive all powerups off of a class (say, Powerup), and use the onAdd function to add the trigger to the item automatically.
#2
10/05/2009 (5:42 pm)
Okay this can be done, didnt know if there was any performance hit in doing it that way...

So basically build a power up, add it to the scene then in the powerups super class code or what not, have an onAdd that adds a trigger. And in the trigger class is like a super of getPowerup or something to that effect, that figures out what powerup it was attached to and assigns it to the player then deletes it and the power up all upon the "on enter" code?

#3
10/05/2009 (6:00 pm)
Dead on, man!
#4
10/05/2009 (10:02 pm)
also, and i think this is a easier way to do it, just assign a static value to that object actin as a power up (say, a TAG that says what kinda power up it is) and in the Collision routine (either the players or the power up) do the validation for that tag... and you're all set.

in addition to that, you create a function that controls the way it disapears when hit (liek you suggest, in the OnEnter callback)... say, a Explode function.
#5
10/05/2009 (11:24 pm)
@Casas - That's how I've approached this is the past but if your player object is moving, usually by a call from %this.setAngularVelocity() when it hits an object (besides a trigger) it will stop the player unless you turn both send and receive collision off (physics off as well).

With the setting this way, the problem is, it won't fire the onCollision callback.

I've run into this a few times.
#6
10/06/2009 (1:19 am)
ohh, can you please give me the power up behavior? I really really need it Im a noob :)
#7
10/06/2009 (7:31 am)
Quote:
That's how I've approached this is the past but if your player object is moving, usually by a call from %this.setAngularVelocity() when it hits an object (besides a trigger) it will stop the player unless you turn both send and receive collision off (physics off as well).

your post sounds just right, but i dont think i have stumbled upon such behaviour... or i just dont remember it.

what if you just deactivate the physics on the POW object?... it shouldnt make the player stop (in theory)...

anyway, if you say it works better with a trigger, then, a trigger should be used... hehe. thx for the info.
#8
10/06/2009 (12:16 pm)
Quote:your post sounds just right, but i dont think i have stumbled upon such behaviour... or i just dont remember it.

I'm by no means trying to indicate that I'm right in my assessment... :) If you have a chance take a look at this prototype that exhibits this behavior when you hit the power up.

Player: send collision, send physics
PowerUp: recieve collision

nice to see you back btw...