Using OnTrigger to make two trigger objects open a door in unityscript.
https://www.youtube.com/watch?v=7tT9LahdBW8
Theirs this video displaying how to make a game with Playmaker in order to match colors on separate triggers to end a game. I thought it would be interesting idea to do this in javascript. Issue I ran across with this figuring out how to make two separate objects that the player collides with to communicate with another object with a script that is enabled in order to unlock or move a door up.
I thought about just going with a addforce without using Itween. How does one pull this off in unityscript?
Thanks.
(didn't watched the video, 50 $$anonymous$$s are way to long!) have a trigger script with referece to the door script. triggerscript -> onTriggerEnter: deactive the trigger script, count a variable in the door script up.
door script -> if counter variable >= 2 (or any other number) -> unlock door
When about using other functions, would it be better add a function update with or without an array list?
what?
DoorScript: needs following variables: currentValue:int (set it to 0 at the beginn), neededValue:int (set it to 2 for your example). the script has a method "TriggerPressed()", where currentValue is incremented by 1. there is an check if currentValue==neededValue. if its true you can unlock the door
TriggerScript has a variable AttachedDoor:DoorScript, which is set in the editor to a reference of the Door it is attached to.
in the OnTriggerenter method call "AttachedDoor.TriggerPressed()" and destroy the trigger script itself.
Your answer
Follow this Question
Related Questions
Having a OnTriggerEnter make another gameobject Add Force in UnityScript. 1 Answer
Rigidbody Addforce not working as expected ( video included) 0 Answers
Rigidbody AddForce() stops working after walking away for a while 0 Answers
How do I get objects in front of the player to be blasted away? 1 Answer