Below is my mobile code:
Using System. The Collections;
using System.Collections.Generic;
using UnityEngine;
Public class playerMove: MonoBehaviour
{
Public Transform myTransform;
Private Ray Ray;
Private RaycastHit mHit;
//whether the switch action
Private bool isCanAutoMove;
Private Vector3 mTargetPos;
Public Animator myAnimator;
Private Camera _myCamera=null;
Public float movespeed=5 f;
Void the Start ()
{
MyTransform=gameObject. GetComponent
_myCamera=Camera. The main;
MyAnimator=GetComponent
}
Void the Update ()
{
//mouse click on a certain point, people to the site
If (Input. GetMouseButton (0))
{
//return a Ray Ray from the camera to the screen the specified point
Ray Ray=_myCamera. ScreenPointToRay (Input. MousePosition);
If (Physics. Raycast (ray, out mHit))
{
If (mHit starts. GameObject. Tag=="plane")
{
MTargetPos=mHit. Point;
Transform. LookAt (new Vector3 (mTargetPos. X, mTargetPos. J y, mTargetPos. Z));
IsCanAutoMove=true;
}
}
}
If (isCanAutoMove)
{
IdelOrRun myAnimator. SetBool (" ", true);
The transform. Translate (Vector3. Movespeed forward * * Time. DeltaTime);
MyTransform. Transform. Translate (Vector3. Movespeed forward * * Time. DeltaTime);
Float short=Vector3. Short (mTargetPos, transform the position);
If (short & lt;=0.5 f)
{
IsCanAutoMove=false;
MyAnimator. SetBool (" IdelOrRun ", false);
}
}
}
}
CodePudding user response:
Unity automatically NavMesh pathfinding functionCodePudding user response:
Well, can you more clearly, which means I did not use the NavMesh, but unity will automatically call?CodePudding user response:
Ghosting is the camera problem, you take a closer look at the camera thisCodePudding user response:
Don't set the camera's Clear Flags for Dont Clear