How to get a spawned actor to stop when it collides with itself

richardcogginrichardcoggin Member Posts: 10
edited October 2012 in Working with GS (Mac)
I'm a newbie at this, so please forgive if this has already been covered.

I am spawning an actor (1) from a point on the stage. This then moves along a path. From the opposite direction another actor approaches and when they meet, they both stop and engage in a shoot out. This works fine. Trouble is, when I spawn another actor (1) which follows the same path, I want it to stop when it collides with the actor (1) in front of it. At present, after trying a few things, it just keeps going past. Imagine all the spawned actors waiting patiently until the one in front has completed it's task and then moves.

I tried using a collision detection, but it didn't recognise it
I tried actor (1) spawning another actor that follows it which had collision detection which didn't work

Any ideas? My eyes are falling out :(

Best Answers

Answers

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    @richardcoggin

    Hi Richard, have you a standard Collide Behaviour in the spawned actor Prototype in the Inspector? i.e Bounce when colliding with actor of type Actor1

    and if you've other different types of actors ou want the spawned actor to collide with, just add more Collide behaviours to its Prototype in the Inspector:

    Bounce when colliding with actor of type Actor2

    Hope that solves it for you; and hope your eyes don't drop out completely.... ;-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • richardcogginrichardcoggin Member Posts: 10
    Thanks a bunch. I tried standard collide, but I think it's something to do with it being the same actor? I couldn't get to work.
  • richardcogginrichardcoggin Member Posts: 10
    So, I've been playing around with all day and still can't get it to work. Does anyone have an idea how this can work.

    What I'm looking I love is how to make identical spawned actors have a collide function so they can't touch each other.

    I've tried basic collide, but the actors still overlap.

    Any help would really be appreciated!
  • famekraftsfamekrafts Member, BASIC Posts: 834
    So, I've been playing around with all day and still can't get it to work. Does anyone have an idea how this can work.

    What I'm looking I love is how to make identical spawned actors have a collide function so they can't touch each other.

    I've tried basic collide, but the actors still overlap.

    Any help would really be appreciated!
    what exactly do you want to do?

    you want them to collide so that they can bounce from one another?

    or you want them to not to collide?
  • famekraftsfamekrafts Member, BASIC Posts: 834
    ok just read your post above:

    Do this when the actor overlaps or collide with actor

    make the self position x to selfposition x + (or -) the width of the actor.

    this way it will always stay behind the actor.
  • richardcogginrichardcoggin Member Posts: 10
    Ideally I'd like the actor behind to stop until the one in front has performed its function. When the one in front moves again, the one behind has permission to move forward again.

    The one in front moves along path and engages with an actor. It stops and shoots. Trouble is, the one behind - following the same path moves over the one in front. I'd like it to wait behind.

    Does that make sense?
  • richardcogginrichardcoggin Member Posts: 10
    Great, thanks. I'm gonna give it go.
  • richardcogginrichardcoggin Member Posts: 10
    Thanks for your help on this, but still am having issues. I tried the self positions, but when the actors collide, the self position moves both the actors. What I need is the second actor to pause behind the first actor without it affecting the first. Any ideas/solutions would be really appreciated.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I tried using a collision detection, but it didn't recognise it
    I'm trying to understand why this might be. If I just add a "When actor collides with [self] actor" it works as expected. I have one actor sitting still and another (copy of the actor) moving towards it. When they touch, the moving actor stops based on the collide rule. Is that not working for you?

    Here's a really simple example of what I'm talking about:


    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • richardcogginrichardcoggin Member Posts: 10
    Thanks for the reply. I'm sure I'm over complicating this somehow.

    I'll try and explain a little more what's going on.

    Actor (A) is spawned and moves along a path. In the opposite direction Actor (B) moves toward it. When they collide. Actor (A) and Actor (B) both stop and spawn bullets. Actor (A) wins and Actor (B) is destroyed. Actor (A) then moves forward again.

    So the function I have is: if collide with Actor (B) stop (using a 'Move to' function), else move (using a 'Move' function)

    Meanwhile, you can spawn another Actor (A) along the same path. So what I've tried to do is put in a Collision Rule which says: if Actor Collides with 'Self' (Actor (A)) stop (using a 'Move to' function)

    The trouble is, is that by applying this rule to Actor (A), when it collides with itself they both stop and are stuck to each other because they both have the same rule.

    So, I tried a Collide Rule which has no effect at all. I then tried a 'Self Position' Rule on the 'X' axis to move the Actors away from each other, but again, both Actor (A)'s are affected.

    What I'm trying to get to is the Actors waiting until the copy Actor in front of them has performed their action; a kind of idle state until the one in front moves on. I wondered if there was anything in creating a Detector Actor that's Spawned, but again I fear I have the same issue whereby it's Spawning the same Detector. It would be good if they had some space between them.

    Do you think it may be a case of creating a grid for the path they are travelling along and if an Actor is on a grid point, the other Actor has to wait.

    I'm making it up now... :) Thanks again for the quick response.
  • richardcogginrichardcoggin Member Posts: 10
    I think I've cracked it. Sound similar to what you have sugested.

    I'm getting the Actor to spawn another actor behind it every 0.1 secs and I'm destroying the spawned actor every 0.05 seconds. The main actor has a collision with the spawned.

    The reason I'm destroying it, is that it has to follow the main actor and not be touching the main actor all the time otherwise it wont move along

    Thanks for your help on this. Hopefully will solve the problem, but will post up my further results as I go along.

    Thanks Tatiang!
Sign In or Register to comment.