Kart Skidding UI
Hello guys im trying to make a kart skidding like mario kart but i have problem with that look my code maybe can u help me with some code or tips.
This is the function of kart
internal void KartIsSkidding(bool isLeft)
{
if (isGrounded)
{
Debug.Log("Recibiendo dato Skidding");
if (isLeft)
{
Debug.Log("Test 1");
Steer = (Steer / 2);
GetComponent<Rigidbody>().AddForce(transform.right * 200, ForceMode.Acceleration);
//GetComponent<Rigidbody>().AddForceAtPosition(new Vector3(80f, 0, 0), kartInterface.Wheels[2].transform.position, ForceMode.Impulse);
}
if (!isLeft)
{
Debug.Log("Test 2");
Steer = (Steer / 2);
GetComponent<Rigidbody>().AddForceAtPosition(new Vector3(-80f, 0, 0), kartInterface.Wheels[3].transform.position, ForceMode.Impulse);
}
}
}
This is the Button UI
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class JumpButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
internal GameObject Listener;
public bool Skidding;
public bool jump;
public float tempSteer;
public float ter;
public void OnPointerDown(PointerEventData eventData)
{
if (Listener != null)
{
if (!jump && Listener.GetComponent<KartControl>().isGrounded)
{
tempSteer = Listener.GetComponent<KartControl>().Steer;
Listener.GetComponent<PlayerControl>().UserActions("Jump");
jump = true;
}
if (Listener.GetComponent<KartControl>().Steer < -.10f)
{
if (Listener.GetComponent<KartControl>().Steer > tempSteer)
{
Skidding = false;
jump = false;
}
else
Skidding = true;
}
else if (Listener.GetComponent<KartControl>().Steer > .10f)
{
if (Listener.GetComponent<KartControl>().Steer < tempSteer)
{
Skidding = false;
jump = false;
}
else
Skidding = true;
}
ter = Listener.GetComponent<KartControl>().Steer;
}
}
public void OnPointerUp(PointerEventData eventData)
{
Skidding = false;
jump = false;
}
}
Comment
Your answer
Follow this Question
Related Questions
What are the property names in the new Unity 5 standard shader 3 Answers
Scripting errors in Unity Ads Import 1 Answer
How to access a live website like google inside the Unity3D scene (gameobject) 2 Answers
Why can I only use unity in Offline mode? 0 Answers
Unity not opening on Ubuntu 15.10 1 Answer