I am trying to develop a script that uses the OnTriggerEnter function. When the player walks into a trigger, they must be pushed up into the air. It sounds like a simple program but for some reason, I just cant get it working. If someone knows how this is done please reply because I am lost!
Still lost on how to achieve this effect. The part I am confused on is, when the player walks into the trigger, what should I use to make the player launch up into the air?
You should attach that script to the box (and set “Is Trigger” to “true” ), then add onto the scene “First Person Controller” and set it’s tag to “Player”.
Um, you want OnTriggerStay, not Enter. This way, the character walks in stays a while. He receives a controller.Move(Vector3.up * upSpeed); The longer he stays the more he receives the up movement.
very simple but you must adjust this code bit more the be more effective IE. if you still stay inside trigger it counts , when you leave it disables. I havent tested this but this is how it should work
Hope it helps.
var upSpeed : float = 10;
var thePlayer : GameObject;
var timer1;
var StartTimer : boolean = false;
function OnTriggerEnter () {
timer1 = 0
StartTimer = true;
Main();
}
function OnTriggerExit () {
timer1 = 0
StartTimer = false;
}
function Main(){
while (Timer1 < 100) {
thePlayer.Move(Vector3.up * upSpeed);
timer1++;
}
}