I’m trying to figure something out, i’m using an XboxOne controller with my car game.
now using the left thumb stick which is assigned to Horizontal , joystick axis and x axis the tire snaps to the direction i turn (left/right) quickly instead of turning the tire smoothly until it reaches the max angle.
while using my keyboard input the tire turns smoothly.
now i can push it smoothly if i push the stick gently to either side but that’s not practical.
my question is, is there a way smooth that action out, going from 0 to 1 smoothly and 0 to -1.
like an incremental increase instead of snapping to 1 if i push it fast to the right?
any help is appreciated
The easiest way is probably by using Mathf.SmoothDamp().
1 Like
Thanks for the response Barons, any idea how would i go to implement that with my input?
my current input script is as follows…
using System;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
using UnityEngine.Networking;
namespace UnityStandardAssets.Vehicles.Car
{
[RequireComponent(typeof (CarController))]
public class CarUserControl : NetworkBehaviour
{
private CarController m_Car; // the car controller we want to use
private void Awake()
{
// get the car controller
m_Car = GetComponent<CarController>();
}
private void FixedUpdate()
{
// if the player is not a local player return and don't pass controls
if (!isLocalPlayer)
return;
// pass the input to the car!
float h = CrossPlatformInputManager.GetAxis("Horizontal");
float v = CrossPlatformInputManager.GetAxis("Vertical");
#if !MOBILE_INPUT
if (!isLocalPlayer)
return;
float handbrake = CrossPlatformInputManager.GetAxis("Jump");
m_Car.Move(h, v, v, handbrake);
m_Car.Move(h, v, v, 0f);
#endif
}
}
}
Thanks for the push to the right direction again, I got to mess with it a bit before I had to leave, it partially worked the tires turned smoothly but I did something wrong that the whole position of the car gets shifted to the direction I turn, bad coding on my part, if you post any thing I’ll be sure to test when I get back.
i couldn’t figure it out still lost i even tried using Lerp that didn’t work.