Locating an Object in Unity 3D
If your end area can be thought of as a field, you can add a BoxCollider to your scene around the finish area and set the property isTrigger
to true. You will then receive a callback OnTriggerEnter
on your entity when it enters the area, which you can later use to finish the level or whatever.
a source to share
As Peter G points to Unity's answers :
If you have a rigid body, you can do Rigidbody.IsSleeping () to check if your rigid person was sleeping.
If you are using a Character Controller, then check that CharacterController.velocity == Vector3.zero;
Or you can manually save the Vector3 in each frame that remembers the last position. Sort of:
function Update () {
curPos = position;
if(curPos == lastPos) {
print("Not moving");
}
lastPos = curPos;
}
a source to share
Well, if you mean the finish area by target area, then you can do this in several ways.
you can use collides
in a simple way: (1) create a plane, create a tag named "finish" (2) then select the player, then click the dropdown "tag" in the inspector. find "finish" and select it. you will also need to add a collider to your game object.
then create new JavaScript and add this code to it
function OnCollisionEnter(collision : Collision){
if(collision.gameObject.tag == "finish"){
//"STOP GAMEOBJECT FROM MOVING"
}
}
or use this method
put this script on your player. this script is probably as god as using colliders for what you are doing
var other : Transform;
function Update ()
{
var dist = Vector3.Distance(other.position, transform.position);
if (dist < 100)
{
//stop player movent here
// move player to exact finish position over time
}
}