Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by netkingZ · Jun 17, 2014 at 04:41 AM · slip

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

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<AutoMove>(); // 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.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image netkingZ · Jun 20, 2014 at 12:51 AM 0
Share

This is the alternative code , but doesn't work.

public class Auto$$anonymous$$ove : $$anonymous$$onoBehaviour { public Vector3[] points; private int currentIndex = -1; ...

void Update() { if(activeAuto$$anonymous$$oveW == true) { Vector3 direction = points[i+1]-points[i]; transform.position += direction $$anonymous$$oveSpeed Time.fixedDeltaTime;

      if((transform.position - points[i+1]).sqr$$anonymous$$agnitude < 0.1f)

//check if we are at the next point currentIndex++; } if(activeAuto$$anonymous$$oveS == true) { Vector3 direction = points[i+1]-points[i]; transform.position -= direction $$anonymous$$oveSpeed Time.fixedDeltaTime;

      if((transform.position - points[i]).sqr$$anonymous$$agnitude < 0.1f)

//check if we are at the next point currentIndex--; }

  if(currentIndex < 0 || currentIndex > points.Length) //check

if we are at either edge of the line and then end the slip { activeAuto$$anonymous$$oveW = false; activeAuto$$anonymous$$oveS = false; {

  ...   }

public void BeginSlip(Vector3[] points) //called from the object when you want to begin the slip { this.points = points; //get the slip points from the object you slip on

  //find the closest point
  float $$anonymous$$Dist = float.$$anonymous$$axValue;
  for(int i=0; i     {
    float currentDist = (transform.position -

points[i]).sqr$$anonymous$$agnitude; if(currentDist < $$anonymous$$Dist) { $$anonymous$$Dist = currentDist; currentIndex = i; } } } }

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

What is the Unit of "Slip" in the Wheel Collider? 3 Answers

How to make Physics2D more "stable" 0 Answers

Decreasing wheel friction with velocity 1 Answer

Simple arcade car Physics 0 Answers

enabling trail renderer 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges