Switching Boolean to true for both actors who collide?

Hello. I'm trying to switch an attribute to true for two actors which collide (change animations), but currently only one actor changes animations and the other doesn't receive the Boolean change. Any and all help would be greatly appreciated.


Sure thing, here it is. As you can see, I want a collision between two actors with this same behavior to trigger both of them switching animations and not being sable to turn. Thanks for any and all help! :)

NobodyX

  • *
  • Posts: 1228
One way to change another actor's attribute is with the block in the first attachment.

But I prefer not to use that block because if you use it on an actor that doesn't have the behaviour, or if at some point you changed the name of the attribute, then it'll crash the game.

What I prefer to do when I want to change another actor's attribute, and what is a very very useful thing to learn about in general for tons of different uses... is "custom events". Attachment 2 gives an example of what you're asking for I think. (The other actor has to trigger that event)

http://www.stencyl.com/help/view/custom-events/

« Last Edit: April 24, 2018, 01:27:14 pm by NobodyX »

NobodyX

  • *
  • Posts: 1228
Oh, and if two things collide then sometimes only one will register the collision. Because when the first one detects the collision the other one could get pushed away or whatever. So it's generally a good idea to use things like I mentioned any time multiple actors are colliding and you want more than one to do something.

Hey, I tried what you said and it doesn't seem to work. One of the actors still doesn't respond to the collision. Did I do anything wrong?

NobodyX

  • *
  • Posts: 1228
When an actor uses the "in this behavior" block it'll only affect itself, not other actors. To have it trigger the other actor you can do it like this:

corbanwolf

  • Posts: 223
How about this?
♪♪♪♪♪♪

YobApp

  • Posts: 57
Hey ! Please explain more and clearly what you want  to do then we can help !
it seems that its not hard thing to do !

YobApp

  • Posts: 57
Maybe this will help you !
try to use the :
For each ( Actor type )  block  Or for each (actor groupe) block
choose your actor type then drop the switch animation in that block  dont forget to change self in switch animation by dragging the tag into it from the for each block !!

Maybe this will help you !
try to use the :
For each ( Actor type )  block  Or for each (actor groupe) block
choose your actor type then drop the switch animation in that block  dont forget to change self in switch animation by dragging the tag into it from the for each block !!

Hi, i tried this but it doesn't work. What I am trying to do is have the event "snapped" make it so that both actors in the same group which collided are then unable to move and switch to an animation as well. Any help?

corbanwolf

  • Posts: 223
Make sure that both actor types physics is normal with updates.
Put the same behaviour in both actor types
♪♪♪♪♪♪

Maybe this will help you !
try to use the :
For each ( Actor type )  block  Or for each (actor groupe) block
choose your actor type then drop the switch animation in that block  dont forget to change self in switch animation by dragging the tag into it from the for each block !!

I do not think this would work. My aim is to make multiple puzzle pieces on a board, hencefourth if I make the actor group all "snap" it will cause each piece to become immovable, I only want the pieces which collide to be immovable

corbanwolf

  • Posts: 223
Trigger event snapped in both those pieces. What do you mean by "it doesn't work"?
♪♪♪♪♪♪

I tired implementing this, because I need the 1st and 2nd actors to trigger "snapped" for themselves only. If I set the entire group to snapped after two of the group members collide the puzzle will not work because then all actors in that group will react when i Only want the actors who collided to react. I tried to do this but it won't work either: