- Home /
DroppableMover Referenced - 3DPlatformer
Not sure why the droppablemover script is referenced when writing an ontrigger function in several of the scripts in the Lerpz tutorial (referenced is the Droppable mover script + an example of an ontrigger function script on a sphere object that Lerpz runs into). The question is why does the DroppableMover script get referenced in the first place? Why is it needed? It seems like it's needed in every script that involves an ontrigger function.
Droppable Mover Script
var gravity = 10.00; var collisionMask : LayerMask;
private var velocity = Vector3.zero; private var position : Vector3;
function Bounce (force : Vector3) { position = transform.position; velocity = force; }
function Update () { velocity.y -= gravity Time.deltaTime; moveThisFrame = velocity Time.deltaTime; distanceThisFrame = moveThisFrame.magnitude;
if (Physics.Raycast(position, moveThisFrame, distanceThisFrame, collisionMask))
{
enabled = false;
}
else
{
position += moveThisFrame;
transform.position = Vector3(position.x, position.y + 0.75, position.z);
}
}
Spherical GameObject Script
var questiontrigger: boolean = false; var mover : DroppableMover; var playerStatus : ThirdPersonStatus; var QuestionMark : GameObject;
function Start () { // do we exist in the level or are we instantiated by an enemy dying? mover = GetComponent(DroppableMover); }
function OnTriggerEnter (col: Collider) { if(mover && mover.enabled) return; var playerStatus : ThirdPersonStatus = col.GetComponent(ThirdPersonStatus); Debug.Log("YES"); if(col.gameObject.tag == "Player") questiontrigger = true; print("questiontrigger = true");
//Destroy(QuestionMark);
}
Answer by Bunny83 · Apr 25, 2011 at 12:55 AM
Well, i never used any tutorials or examples like this, but the DroppableMover script is just a script to drop the object it is attached to, to the ground. In the Spherical script, that should be attached to the same object, is the line:
if(mover && mover.enabled) return;
that aborts the OnTriggerEnter function if the object have such a DroppableMover script and the object is not dropped yet. This is done to prevent getting a collision when the object hits the ground during the dropping procedure.
It is not needed in your scripts when you don't use the DroppableMover script along with your script.
Your answer
![](https://koobas.hobune.stream/wayback/20220613125042im_/https://answers.unity.com/themes/thub/images/avi.jpg)