- Home /
Question by
Mohammedunity · Jun 12, 2017 at 08:46 AM ·
movementmultiplayercarinputmanager2 player
Second player not moving sucks in its place?
I used unity assent in my project,, i import the car its work fine then i copy the car ,when i play the game it seems both are moving with my wasd buttons i go to change in the input setting i add 2 more input. the i copy user car script and i edit it , rename it mapping it to the second car
code of user car script P2
using System;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
namespace UnityStandardAssets.Vehicles.Car
{
[RequireComponent(typeof (CarController))]
public class P_CarUserContral : MonoBehaviour
{
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()
{
// pass the input to the car!
float r = CrossPlatformInputManager.GetAxis("right/left");
float u = CrossPlatformInputManager.GetAxis("up/down");
#if !MOBILE_INPUT
float handbrake = CrossPlatformInputManager.GetAxis("Jump");
m_Car.Move(r, u, u, handbrake);
#else
m_Car.Move(h, v, v, 0f);
#endif
}
}
}
the input setting is
Help Help
capturejjjj.png
(22.8 kB)
Comment