Trigger elevator.. i am missing something obvious..

I am makin a simple elevator, but i cant even get it to start moving?!
The script i am using is attached to the elevator platform and sees when the “ElevatorTrigger” attached to the bottom of my char touches it.

function OnTriggerStay (Trigger : Collider) {
	if (Trigger.gameObject.name=="ElevatorTrigger"){
		transform.position.y +=.1;
		print ("Success");
	}
}

What am i missing? And yes, i am 100% sure that the trigger is called “ElevatorTrigger”

Thx in advance, Sigvard.

EDIT

I just tested the script using

function OnTriggerEnter (Trigger : Collider) {
		print ("Success");
}

and that doesn’t even work… what can be the cause of this? It seems very weird to me…

Try changing the .1 to 0.1

If thats not it ask again:)

You need to put the “OnTriggerX” event on the trigger object. Non-trigger colliders never call OnTrigger events, and trigger colliders never call OnCollision events.

So, put the following on your player’s foot trigger thing:

var playerObject : GameObject;
var distancePerSecond : float;

function OnTriggerStay( trigger : Collider ) {
  if ( trigger.gameObject.tag == "Elevator" ) {
    trigger.transform.position.y += Time.deltaTime * distancePerSecond;
    playerObject.transform.position.y += Time.deltaTime * distancePerSecond;
  }
}

Whenever the player stands on an object tagged as an Elevator, it’ll rise.

You’ll need to assign the main player object to playerObject, and later you’ll want to move distancePerSecond into the actual elevator object if you want different elevators to have different speeds.

Oh yea, thats right… well it has been a while since i used Unity so this is the kind of simple stuff you forget :slight_smile: I looked at your solution, and found it perfect for my purpose, but… it still doesn’t work.
before even testing it i changed the

  if ( trigger.gameObject.tag == "Elevator" ) {
to
  if ( trigger.gameObject.name== "Platform" ) {

so that i didn’t have too many tags, but that didn’t work, so i went back and made a “Elevator” tag but it still wont move… and yes i remembered to set the speed and playerobject. Any ideas?

If the GameObject doesn’t have a trigger it wont work
Just add a box collider component and move it above the platform/elevator in the inspector and after you did that check isTrigger
Colliders and triggers cause diffrent events to occure

Trigger //Can be moved through good for use as a area affect-tor

calls the OnTrigger#### family of events
takes a collider as it’s parameter

Colliders // are triggers that cause collisions , they are solid

calls the OnCollision#### family of events
takes a collision as it’s parameter

Please read previous replies before commenting.