How to get a spawned actor to stop when it collides with itself
richardcoggin
Member Posts: 10
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
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
-
tatiang Posts: 11,949I do think the solution lies in having a "detector" actor. When I get a chance, I'll try to recreate that and see if it works.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
-
tatiang Posts: 11,949Okay, what do you think of this? If you click and hold the lead white actor, it stops. The red actors are detector actors. If that's what you're looking to do, I can explain a bit more about how it works.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Answers
@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
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!
you want them to collide so that they can bounce from one another?
or you want them to not to collide?
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.
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?
Here's a really simple example of what I'm talking about:
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
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.
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!