using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.Characters.FirstPerson;
public class wallrun : MonoBehaviour {
private RigidbodyFirstPersonController cc;
private Rigidbody rb;
private int jumpCount = 0;
private bool isWallL = false;
private bool IsWallR = false;
private RaycastHit hitR;
private RaycastHit hitL;
public bool wallTouch;
// Use this for initialization
void Start () {
cc = GetComponent<RigidbodyFirstPersonController> ();
rb = GetComponent<Rigidbody> ();
}
void OnCollisionEnter(Collision col) {
if (col.gameObject.tag == "jumpWall")
wallTouch = true;
}
void OnCollisionExit (Collision col){
if (col.gameObject.tag == "jumpWall")
wallTouch = false;
}
// Update is called once per frame
void Update () {
if (IsWallR == true)
// here i want some script that makes the camera rotate about 45 degrees in left/right directions
if (isWallL == true)
// here i want some script that makes the camera rotate about 45 degrees in left/right directions
if (IsWallR == false && isWallL == false)
//here i want a script that makes the camera go back to normal again.
if (cc.Grounded)
jumpCount = 0;
if (!cc.Grounded && jumpCount <= 1) {
if (Physics.Raycast (transform.position, transform.right, out hitR, 1)) {
if (hitR.transform.tag == "jumpWall" && wallTouch == true && cc.movementSettings.Running == true && speedmeter.speed >= 0.133f) {
IsWallR = true;
isWallL = false;
jumpCount += 1;
rb.useGravity = false;
StartCoroutine (afterRun ());
}
}
if (Physics.Raycast (transform.position, -transform.right, out hitL, 1)) {
if (hitL.transform.tag == "jumpWall" && wallTouch == true && cc.movementSettings.Running == true && speedmeter.speed >= 0.0133f) {
isWallL = true;
IsWallR = false;
jumpCount += 1;
rb.useGravity = false;
StartCoroutine (afterRun ());
}
}
}
}
IEnumerator afterRun() {
yield return new WaitForSeconds (1);
isWallL = false;
IsWallR = false;
rb.useGravity = true;
}
}
How do you do this? It doesnt work with transform.rotate at all.
Help appreciated.