Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[RELEASED] Simple Motocross Physics

Discussion in 'Assets and Asset Store' started by AiKodex, Aug 8, 2022.

  1. Wun5

    Wun5

    Joined:
    Oct 15, 2021
    Posts:
    7
    Wheel colliders have not yet been decided
    Spheres are incredibly bad for maneuvering
     
  2. Wun5

    Wun5

    Joined:
    Oct 15, 2021
    Posts:
    7
    And the last
    Can I join your team?
     
  3. rickeyunity

    rickeyunity

    Joined:
    Oct 24, 2017
    Posts:
    1
    Bom dia, seu ativo é incrível Estou muito satisfeito com a compra, mas gostaria de saber como posso adicionar satisfatoriamente partículas de poeira e marcas de derrapagem na roda traseira?
     
  4. MaxKMadiath

    MaxKMadiath

    Joined:
    Dec 10, 2016
    Posts:
    67
    any update waiting for it :)
     
  5. fertel

    fertel

    Joined:
    Jul 3, 2018
    Posts:
    9
    Hi, there is some option to add AI controlled motorcycle?
     
  6. Kotique333

    Kotique333

    Joined:
    Sep 5, 2020
    Posts:
    1
    Hi! It seems like I have similar issues in Physics and Moto controller and I guess it is due to some lack of understanding. When motorcycle making a backflip it seems like the script tries to realign the vehicle and rotates it back but in opposite direction. Is there any chance to make it not happen?
     
  7. max94game

    max94game

    Joined:
    Feb 25, 2020
    Posts:
    2
    Hey Gays! I'm new in c# and Unity so I want to reset rag doll player on mobile when press button instead of key "R" how can I do this
     
  8. abdullboy

    abdullboy

    Joined:
    Oct 21, 2021
    Posts:
    2
    I downloaded the simple motorcross physics and installed the package to unity v202.3.14f1 I got a lot of errors immediately after it was installed I checked the unity forum for answers even youtube but there was no solution to my problem.
    I think the problem is coming from the MotoAnimController.cs file, here is the source code for the file:

    Code (CSharp):
    1. using System.Collections;
    2. using UnityEngine;
    3. using UnityEngine.Animations.Rigging;
    4. namespace SMPScripts
    5. {
    6.     public class MotoAnimController : MonoBehaviour
    7.     {
    8.         MotoController motoController;
    9.         Animator anim;
    10.         string clipInfoCurrent, clipInfoLast;
    11.         [HideInInspector]
    12.         public float speed;
    13.         [HideInInspector]
    14.         public bool isAirborne;
    15.  
    16.         public GameObject hipIK, chestIK, leftFootIK, leftFootIdleIK, headIK;
    17.         MotoStatus motoStatus;
    18.         Rig rig;
    19.         bool onOffBike;
    20.         [Header("Character Switching")]
    21.         [Space]
    22.         public GameObject characterGeometry;
    23.         public GameObject externalCharacter;
    24.         float waitTime;
    25.         void Start()
    26.         {
    27.             motoController = FindObjectOfType<MotoController>();
    28.             motoStatus = FindObjectOfType<MotoStatus>();
    29.             rig = hipIK.transform.parent.gameObject.GetComponent<Rig>();
    30.             if (motoStatus != null)
    31.                 onOffBike = motoStatus.onBike;
    32.             if (characterGeometry != null)
    33.                 characterGeometry.SetActive(motoStatus.onBike);
    34.             if (externalCharacter != null)
    35.                 externalCharacter.SetActive(!motoStatus.onBike);
    36.             anim = GetComponent<Animator>();
    37.             leftFootIK.GetComponent<TwoBoneIKConstraint>().weight = 0;
    38.         }
    39.  
    40.         void Update()
    41.         {
    42.             if (characterGeometry != null && externalCharacter != null)
    43.             {
    44.                 if (Input.GetKeyDown(KeyCode.Return) && motoController.transform.InverseTransformDirection(motoController.rb.velocity).z <= 0.1f && waitTime == 0)
    45.                 {
    46.                     waitTime = 1.5f;
    47.                     externalCharacter.transform.position = characterGeometry.transform.root.position - transform.right * 0.5f + transform.forward * 0.1f;
    48.                     motoStatus.onBike = !motoStatus.onBike;
    49.                     if (motoStatus.onBike)
    50.                     {
    51.                         anim.Play("OnBike");
    52.                         StartCoroutine(AdjustRigWeight(0));
    53.                     }
    54.                     else
    55.                     {
    56.                         anim.Play("OffBike");
    57.                         StartCoroutine(AdjustRigWeight(1));
    58.                     }
    59.                 }
    60.             }
    61.             waitTime -= Time.deltaTime;
    62.             waitTime = Mathf.Clamp(waitTime, 0, 1.5f);
    63.  
    64.             speed = motoController.transform.InverseTransformDirection(motoController.rb.velocity).z;
    65.             isAirborne = motoController.isAirborne;
    66.             anim.SetFloat("Speed", speed);
    67.             anim.SetBool("isAirborne", isAirborne);
    68.             if (motoStatus != null)
    69.             {
    70.                 if (motoStatus.dislodged == false)
    71.                 {
    72.                     if (!motoController.isAirborne && motoStatus.onBike)
    73.                     {
    74.                         clipInfoCurrent = anim.GetCurrentAnimatorClipInfo(0)[0].clip.name;
    75.                         if (clipInfoCurrent == "IdleToStart" && clipInfoLast == "Idle")
    76.                             StartCoroutine(LeftFootIK(0));
    77.                         if (clipInfoCurrent == "Idle" && clipInfoLast == "IdleToStart")
    78.                             StartCoroutine(LeftFootIK(1));
    79.                         if (clipInfoCurrent == "Idle" && clipInfoLast == "Reverse")
    80.                             StartCoroutine(LeftFootIdleIK(0));
    81.                         if (clipInfoCurrent == "Reverse" && clipInfoLast == "Idle")
    82.                             StartCoroutine(LeftFootIdleIK(1));
    83.  
    84.                         clipInfoLast = clipInfoCurrent;
    85.                     }
    86.                 }
    87.                 else
    88.                 {
    89.                     characterGeometry.SetActive(false);
    90.                     if(Input.GetKeyDown(KeyCode.R))
    91.                     {
    92.                         characterGeometry.SetActive(true);
    93.                         motoStatus.dislodged = false;
    94.                     }
    95.                 }
    96.             }
    97.             else
    98.             {
    99.                 if (!motoController.isAirborne)
    100.                 {
    101.                     clipInfoCurrent = anim.GetCurrentAnimatorClipInfo(0)[0].clip.name;
    102.                     if (clipInfoCurrent == "IdleToStart" && clipInfoLast == "Idle")
    103.                         StartCoroutine(LeftFootIK(0));
    104.                     if (clipInfoCurrent == "Idle" && clipInfoLast == "IdleToStart")
    105.                         StartCoroutine(LeftFootIK(1));
    106.                     if (clipInfoCurrent == "Idle" && clipInfoLast == "Reverse")
    107.                         StartCoroutine(LeftFootIdleIK(0));
    108.                     if (clipInfoCurrent == "Reverse" && clipInfoLast == "Idle")
    109.                         StartCoroutine(LeftFootIdleIK(1));
    110.  
    111.                     clipInfoLast = clipInfoCurrent;
    112.                 }
    113.             }
    114.         }
    115.  
    116.         IEnumerator LeftFootIK(int offset)
    117.         {
    118.             float t1 = 0f;
    119.             while (t1 <= 1f)
    120.             {
    121.                 t1 += Time.deltaTime*3;
    122.                 leftFootIK.GetComponent<TwoBoneIKConstraint>().weight = Mathf.Lerp(-0.05f, 1.05f, Mathf.Abs(offset - t1));
    123.                 leftFootIdleIK.GetComponent<TwoBoneIKConstraint>().weight = 1 - leftFootIK.GetComponent<TwoBoneIKConstraint>().weight;
    124.                 yield return null;
    125.             }
    126.  
    127.         }
    128.         IEnumerator LeftFootIdleIK(int offset)
    129.         {
    130.             float t1 = 0f;
    131.             while (t1 <= 1f)
    132.             {
    133.                 t1 += Time.deltaTime*3;
    134.                 leftFootIdleIK.GetComponent<TwoBoneIKConstraint>().weight = Mathf.Lerp(-0.05f, 1.05f, Mathf.Abs(offset - t1));
    135.                 yield return null;
    136.             }
    137.  
    138.         }
    139.         IEnumerator AdjustRigWeight(int offset)
    140.         {
    141.             StartCoroutine(LeftFootIK(1));
    142.             if (offset == 0)
    143.             {
    144.                 characterGeometry.SetActive(true);
    145.                 externalCharacter.SetActive(false);
    146.             }
    147.             float t1 = 0f;
    148.             while (t1 <= 1f)
    149.             {
    150.                 t1 += Time.deltaTime*3;
    151.                 rig.weight = Mathf.Lerp(-0.05f, 1.05f, Mathf.Abs(offset - t1));
    152.                 yield return null;
    153.             }
    154.             if (offset == 1)
    155.             {
    156.                 yield return new WaitForSeconds(0.2f);
    157.                 characterGeometry.SetActive(false);
    158.                 externalCharacter.SetActive(true);
    159.                 // Matching position and rotation to the best possible transform to get a seamless transition
    160.                 externalCharacter.transform.position = characterGeometry.transform.root.position - transform.right * 0.5f + transform.forward * 0.1f;
    161.                 externalCharacter.transform.rotation = Quaternion.Euler(externalCharacter.transform.rotation.eulerAngles.x, characterGeometry.transform.root.rotation.eulerAngles.y + 80, externalCharacter.transform.rotation.eulerAngles.z);
    162.             }
    163.  
    164.         }
    165.     }
    166. }
    167.  
     

    Attached Files:

  9. meethi

    meethi

    Joined:
    Sep 12, 2016
    Posts:
    3
    Hi,

    We are experiencing similar issues like Saad who left a recent review. What exactly is the fix for the motorbike turning the otherway?

    Saad_Khawajaon version 1.3
    Awful for terrains and ramps
    4 months ago
    DO NOT BUY this asset if you plan on using it on terrains and ramps. e.g a motocross style racing

    The landings are extremely buggy. Your bike rolls over, turns the other way etc. You won't be able to fix this issue well no matter what you try

    After a lot of back and forth with the publisher in which I even sent a package to reproduce the issue (which basically occurs every single time when the bike lands back on the ground), they said "your issue is tricky"

    It is not "my issue". It's a fundamental flaw in the package which the publisher refuses to spend time on.
     
  10. usamanawaz789

    usamanawaz789

    Joined:
    May 20, 2018
    Posts:
    3
    There is an issue I am facing. The issue is that the controls are not working well on mobile. It doesn't take the input again when sometimes buttons are touched rapidly. Can you tell me how to make it correct?