Throwing an object to another object (target)...

LynkkLynkk Member, PRO Posts: 11
edited March 2014 in Working with GS (PC)

Hi!

I need help from you guys :blush:

I'm trying to make a game where the players throw an object (a piece of meat) to a target (a plate).

The throwing part is done, it's not the problem.

My problem is the target is in a fix position but once the target is hit by the object, the target does not respawn.

Here what I did so far:

  • I created a boolean called 'Collision'
  • I created an integer called 'Score' 0
  • I created an object called Meat
  • I created an object called Plate

In my throwing object, the piece of meat, called Meat:

-1st RULE:

  • If Game.Collision is False

2nd RULE:
// I set a specific amount for the velocity where it can hit the target (the game is in 'portrait mode').

  • If self.motion.linearVelocity.y >= 500
  • If self.motion.linearVelocity.y <= 700
  • Actors overlaps or collides with Actor of Type 'Plate'
  • Do
  • change attribute
  • set: game.Collision to True.
  • Destroy
  • destroy this actor
  • Spawn Actor (to respawn the piece of Meat)

In my target object, called Plate:

RULE:

  • If game.Collision is True
  • Do
  • set game.Score to game.Score+10
  • an Animation
  • Destroy
  • destroy this actor
  • Spawn Actor (to respawn the plate)

Okay my problem is when I do Spawn Actor for the plate, the game freezes (loop?).

Actually I do not want the plate to disappear at all, I just want the meat to land on the plate (if the player aims correctly), and the meat to respawn if it reaches the target.

Also the problem is the meat disappears when colliding with the side of the plate, I wish it would disappear on top of the plate (i guess i can reduce the collision box?)

Any help is would be greatly appreciated! I'm stuck :open_mouth:

Comments

  • LynkkLynkk Member, PRO Posts: 11

    No one? :'(

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    Perhaps its a logic error? For example, both actors are being destroyed. Then after they are destroyed (and are gone) they are then supposed to re-spawn themselves. Try putting the spawn behavior before the destroy behavior.

  • LynkkLynkk Member, PRO Posts: 11

    Thanks for your advice but it didn't work.

    All I am trying to do is reset the target so it can be used again.

    i'm trying to put back game.collision to False after it is being hit, but it doesn't work it stays to True for some unknown reasons to me :(

    All I need to do is reset the plate (target) :(

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879
    edited March 2014

    OK -- then get rid of the spawning and destroying idea altogether. Its just messing things up.

    You probably just want to reset the meat back to its original starting position? Yes?

    Try this in the meat actor --

    When meat collides or overlaps with plate
    --Change Attribute: self.Position.X to 100
    --Change Attribute: self.Position.Y to 100
    

    You can change the "100" to whatever the starting position is supposed to be.

Sign In or Register to comment.