Pick up an item and 'throw' it.

Hello all.
I'm a newb and I need some help. In my game I have set up a number of items (bombs) to spawn at random coordinates. These bombs each have a timer to countdown to their explosion.
I want my player character actor to pickup an item upon collision, then throw it when i tap the screen/button.. I tried creating a boolean game attribute called PickupBomb set to false. I put some logic on a bomb actor that went something like:
''when actor receives event collision with actoroftype player, AND if PickupBomb=false,
change atrribute PickupBomb =PickupBomb=true, destroy actor"
Then I put this onto my player actor: "if attribute PickupBomb=true, AND attribute GameButtonPressed=true,
spawn bombthrow 0,0, relative to actor, change attribute PickupBomb=false"
It doesn't seem to be working as I have 2 issues:
1. I think the PickupBomb boolean is broken because i can pickup (destroy on collision) all bombs on screen.
2. My player wont spawn the actor.
Could anyone help with this?
I'm a newb and I need some help. In my game I have set up a number of items (bombs) to spawn at random coordinates. These bombs each have a timer to countdown to their explosion.
I want my player character actor to pickup an item upon collision, then throw it when i tap the screen/button.. I tried creating a boolean game attribute called PickupBomb set to false. I put some logic on a bomb actor that went something like:
''when actor receives event collision with actoroftype player, AND if PickupBomb=false,
change atrribute PickupBomb =PickupBomb=true, destroy actor"
Then I put this onto my player actor: "if attribute PickupBomb=true, AND attribute GameButtonPressed=true,
spawn bombthrow 0,0, relative to actor, change attribute PickupBomb=false"
It doesn't seem to be working as I have 2 issues:
1. I think the PickupBomb boolean is broken because i can pickup (destroy on collision) all bombs on screen.
2. My player wont spawn the actor.
Could anyone help with this?
Comments
offset must be calculated so the bomb will not stick to the body but more to the hands of the character.
hope this helps.
I'm trying to do it now and I'm putting a collision rule onto the bomb for when my player character touches it. Then I added a constrain attribute - self position x,y but i cant seem figure out how to link it to my player since i cant get the player's position through the menu. Any ideas?
On your character put this rule constrain game.characterX to self.position.x
constrain game.characterY to self.position.y
So on the bomb set the rule upon collision with character constrain self.position.x to game.characterX+offset
constrain self.position.x to game.characterY+offset
Hope this give you a clearer picture :P
pic 1 just shows the game attributes
pic2 is the contrain rule for the player character (im using one of the official templates for controls)
pic3 is the bomb