Pick up an item and 'throw' it.

ZeroCredibilityZeroCredibility Member Posts: 16
edited January 2012 in Working with GS (Mac)
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?

Comments

  • SlickZeroSlickZero Houston, TexasMember, Sous Chef Posts: 2,870
    Have you seen this video? It may be what you need.

  • ZeroCredibilityZeroCredibility Member Posts: 16
    Thanks for the video. My mistake, I didn't make myself clear - I meant that I want my player character to pickup an item then throw it when i tap the screen/button.
  • ZeroCredibilityZeroCredibility Member Posts: 16
    Still struggling with this one. I've rebuilt my prototype-so-far twice today...I just want my little dude to walk over an bomb - bomb either disappears or is physically attached to little dude as he walks around - then i want to be able to used the picked up bomb item as a projectile.

  • ultimaultima Member, PRO Posts: 1,207
    well. like you said it can disappear, and change your character spirit sheet to images holding object, and then when you throw it... just have an actor project out.. (while the main actor reverts back to images holding no object.)
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    Well i think another way without destroying the bomb actor is have on collision with bomb, constrain bomb's x,y to character's x+offset,y+offset
    offset must be calculated so the bomb will not stick to the body but more to the hands of the character.
    hope this helps.
  • ZeroCredibilityZeroCredibility Member Posts: 16
    @GLGames That would probably the way to do it that makes most sense in my case. Thanks a lot.

    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?
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    First create 2 real game attribute for your character's x & y. (ex. characterX , characterY)
    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
  • ZeroCredibilityZeroCredibility Member Posts: 16
    Yes it does. I'm 3 days into GameSalad and Learning so much! Only now my bombs disappear on collision instead of attaching themselves to my character - I wonder if it hs anything to do with how the layering is set up. As of now the bombs are in front of my player character. I'm wondering if they are being put underneath when they are getting picked up.
  • ZeroCredibilityZeroCredibility Member Posts: 16
    I now see the appear for a moment bottom left of the screen x,y ,0,0
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    you shouldn't have the destroy actor rule in your bomb if you want it to be picked up by the character.
  • ZeroCredibilityZeroCredibility Member Posts: 16
    I don't have the destroy actor tied to the collision - i do use it on the explosion rule i have which is connected to a timer. i tried shutting off the explosion stuff to see if it makes a difference..it doesnt. It's definitely 'trying' to constrain to the player characters position, but is somehow getting stuck at x,y 0,0 then dissapearing
  • ZeroCredibilityZeroCredibility Member Posts: 16
    ha, this is fun/wierd. There was a bounce attached to the bomb that i forgot to remove. Now when i try to pick up the bomb, it teleports to the 0,0 of the screen and continues its countdown and explosions
  • ZeroCredibilityZeroCredibility Member Posts: 16
    Still stuck on this one. I followed @GLGames suggestions with my existing bomb actors, and some blank actors created for testing, each time - instead of constraining to my player characters position, the actors just move to the scene's x,y 0,0 position.
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    Can you show me the rule you put for the constrain ?
  • ZeroCredibilityZeroCredibility Member Posts: 16
    edited January 2012
    Here you go - Thanks for taking a look. http://imgur.com/a/hIBuP

    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

  • ZeroCredibilityZeroCredibility Member Posts: 16
    Thanks - I finally solved it. I was making changes to the prototype - but not the actor in my scene. She the item i was trying to constrain just went to the default 0,0
Sign In or Register to comment.