Detect If collision is happening between spawned actor(s) and one sensor

Jayko

  • Posts: 56
Hi

Firstly I would like to thank everyone that helped me in the previous posts.
Its not easy but I am ploughing (or plowing :P) through! :) Getting better and better, and Im loving Stencyl more and more.


Now to the question, but first the gist:


I have a couple actors spawning, maximum of 3 at the same time could be on screen.
I managed to make the actors get names so that I could call them up, and give them actor attributes.
They are called actor1, actor2, actor3 (their Actor Attributes).
I also have a sensor in the scene, which is placed there "by hand" in the scene instead of code.

I would like to detect IF the spawned actor collides with the sensor.
Now this is tricky because there is no IF actor A collides with actor B, only WHEN in the event editor.
And it seems that WHEN calculates only once for the original actor spawning, the first actor, and not the other instances (Not the other Actor Atributes).
So seems like WHEN doesnt work with spawning actors by code?

Is there a way I could make something similar to:

Always
IF actor1 collides with sensor
IF actor2 collides with sensor
IF actor2 collides with sensor


And like I mentioned, "Always" instead of "When", so that it checks always?

Is it possible to do all this and still retain the ability to point out to each actor attribute (ie, point out to Actor1, Actor2, Actor3) instead of having to point using Last Created Actor? And still do this without the 1009 code error (which is calling an actor that isnt spawned yet).

Once again thanks for the help, Ive been sitting on this for ages and trying to find some answers to no avail.

Cheers! :)


« Last Edit: August 05, 2014, 12:41:40 pm by Jayko »

PhilIrby

  • Posts: 545
Here is a simple scene behavior that works with your situation.  The rectangle is a sensor placed in the scene and the ball actors are spawned at runtime.

Edit: This uses the actor type-actor type collision option.

« Last Edit: August 06, 2014, 04:27:44 am by PhilIrby »

Jersmall

  • Posts: 30
you can create create if group name has a collision with group name do this.

its in the extra options like you add a new behavior under collisions its not in the list no the right. it looks like 4 blue arrows .
LEARN PROFESSIONAL PHOTO EDITING, CLICK HERE

Jayko

  • Posts: 56
Thank you very much for your replies :)

I am going to work on this and take your pointers into consideration.

Cheers!