Quantcast
Channel: Questions in topic: "slip"
Viewing all articles
Browse latest Browse all 49

How to have player “slide” on pipes and rails?

$
0
0
Hello , i need to create a skid or slips effect. I want create the skid or slips effect as in sunset overdrive : http://www.goodgamebro.com/omega/wp-content/uploads/2014/06/sunset-overdrive-e3-rollercoaster-1.jpg , when the main character slips on the electrical cables and on the rails. how can I create the same result? in C#. See this video: https://www.youtube.com/watch?v=zXjNkoQQPls (from 1.20 min to 1.25) . I have create this code: -OnTrigger- (apply to electric cables) using UnityEngine; using System.Collections; public class OnTriggerEnterScroll : MonoBehaviour { /*ISTRUZIONI : Inserire questo Script all'interno dell'Elemento che entra in contatto con il Trigger */ public Transform target; // Player AutoMove AutoMoveScript; // richiamo variabili Script AutoMove // Use this for initialization void Start () { AutoMoveScript = target.GetComponent(); // Richiano componente AutoMove } // Update is called once per frame void Update () { Vector3 targetDir = target.position - transform.position; Debug.Log(targetDir); } void OnTriggerEnter(Collider other) { // Quando il player entra nel Trigger if(other.collider.name == "MainCharacter"){ AutoMoveScript.MoveSpeed = 8; // Cambio variabile di Velocita' AutoMoveScript.activeAutoMoveW = true; // Cambio variabile di scorrimento AutoMoveScript.activeAutoMoveS = false; // Cambio variabile di scorrimento } } void OnTriggerStay(Collider other) { // Quando il player e' nel Trigger if(other.collider.name == "MainCharacter"){ if(Input.GetKey(KeyCode.W)){ AutoMoveScript.activeAutoMoveW = true; // Cambio variabile di scorrimento AutoMoveScript.activeAutoMoveS = false; // Cambio variabile di scorrimento } if(Input.GetKey(KeyCode.S)){ AutoMoveScript.activeAutoMoveS = true; // Cambio variabile di scorrimento AutoMoveScript.activeAutoMoveW = false; // Cambio variabile di scorrimento } } } void OnTriggerExit(Collider other) { // Quando il player esce nel Trigger if(other.collider.name == "MainCharacter"){ AutoMoveScript.MoveSpeed = 8; // Cambio variabile di Velocita' AutoMoveScript.activeAutoMoveS = false; // Cambio variabile di scorrimento AutoMoveScript.activeAutoMoveW = false; // Cambio variabile di scorrimento } } } -AutoMove- (apply on main Character) using UnityEngine; using System.Collections; public class AutoMove : MonoBehaviour { /*ISTRUZIONI : Inserire questo Script all'interno del Player */ public bool activeAutoMoveW = false; //variabile controllo Forward public bool activeAutoMoveS = false; //variabile controllo Back public int MoveSpeed = 8; //variabile velocità di scorrimento public bool activeSelect = false; //variabile controllo Select // Use this for initialization void Start () { } // Update is called once per frame void Update () { if(activeAutoMoveW == true) { transform.Translate(Vector3.forward * MoveSpeed * Time.fixedDeltaTime, Space.World); // Scorrimento in avari } if(activeAutoMoveS == true) { transform.Translate(Vector3.back * MoveSpeed * Time.fixedDeltaTime, Space.World); // Scorrimento in dietro } if(Input.GetKeyDown(KeyCode.Q) && activeSelect == false) { MoveSpeed = 1; // Cambio variabile di scorrimento activeSelect = true; // Cambio variabile Slect }else if(Input.GetKeyDown(KeyCode.Q) && activeSelect == true) { MoveSpeed = 8; // Cambio variabile di scorrimento activeSelect = false; // Cambio variabile Slect } } } The system create the slips effect but don't understand what is the direction of the character.

Viewing all articles
Browse latest Browse all 49

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>