// sphere detector. To give the collision object within collision range
Collider [] enemys = Physics.OverlapCapsule(bengin,end,attackRange * 5, needJude);
//获取layer设置的内容
LayerMask.GetMask (new string [] {TagLayerType.hero.ToString (), TagLayerType.crytal.ToString (), TagLayerType.soldier.ToString (), TagLayerType.tower.ToString ()});
// used to access scripts on child objects
AttackRangeCircle.GetComponentInChildren (). Color
// set the maximum value of the return direction. 1
desireForward.Normalize ();
// get the coordinates of the square root of
walkSpeed = desireForward.magnitude;
// points to the direction of movement in front
transform.rotation = Quaternion.Lerp (transform.rotation, Quaternion.LookRotation (desireForward), RotaionSpeed Time.fixedDeltaTime *);
/ **
Time.fixedDeltaTime readable and writable
Time.dateTime; only read
*/
// set toward the target point
transform.LookAt (transform);
// set the movement coordinates modifies its coordinate system moves from an initial target point
transform.Translate ((CurrentTarget.transform.position - transform.position) .normalized MoveSpeed Time.deltaTime);
// the content object in the world coordinate system does not change depending on the angle
transform.Position + = new Vector3 (0,0,1) ;
// rigid body movement (friction force more realistic effect)
Rigidbody Rigid = null;
rigid.velocity = new new Vector3 (5F, 0,0);
rigid.MovePosition (transform.position * + transform.forward Time.daltaTime);
IF (Rigid! = null)
{
// if using a rigid body moving rigid
}
the else
{
// coordinate movement using
}
Mobile navigation //
public NavMeshAgent - Agent = null;
Agent.Move (desireForward Time.deltaTime * * HeroSpeed);
// use gameobject object to get the body of the script can not find the way out of the hidden content
//GameObject.Find ( "name");
// find nodes in more than a component
//GameObject.FindChild ( "name");
// find the first active object
GameObject obj = Tranfrom.FindObjectOfType ();
// Find multiple nodes the same level and all of a sudden
GameObject obj = Tranfrom.FindObjectOfTypeAll ();
// Find the child node assembly
getCompoentInChildren ();
// call the parent body of the script object
getCompoentInParent ();
// determine the current operation
IF (animator.GetCurrentAnimatorStateInfo (0) .IsName ( "the Idle"))
{
// If the standing state is not displayed attack ring
isAttacking = to false;
}
the else {
isAttacking = to true;
}