- Home /
Duplicate Question
how can i let my player move converse?
hi!I want to let my player move converse after he touch a box colider.
that my scripts:
public float WalkSpeed=5F;
public float RunSpeed=10F;
public float rotationmove=-1;
void Update () {
AutoWalk();
if(Input.GetKeyDown(KeyCode.P))
{
Run ();
} if(Input.GetKeyUp(KeyCode.P)) { Walk(); animation .Play ("walk"); }
void AutoWalk()
{
animation.Play("walk");
controller.SimpleMove(Vector3.right * WalkSpeed);
} void Walk()
{ animation.Play("walk"); WalkSpeed=5; RunSpeed=WalkSpeed; RunSpeed=10; } void Run() { //controller.SimpleMove(Vector3.right * RunSpeed); WalkSpeed=RunSpeed; runtime=Time.time; animation .Play ("run"); }
void OnControllerColliderHit(ControllerColliderHit hit) {
if( hit.gameObject.tag == "Door") { Destroy(hit.gameObject); WalkSpeed=WalkSpeed*rotationmove; RunSpeed=RunSpeed*rotationmove; /WalkSpeed=-2.5F; RunSpeed=-5F;/ } /*if( hit.gameObject.tag == "water") { WalkSpeed=2.5F; RunSpeed=5F; //gameObject.transform.localScale += new Vector3(1F, 0.0F, 1F);
}*/