- Home /
Negitive Input Problem
I have created a splitscreen game that has two characters shoot at each other. The both have different moving scripts and inputs. But for the second player is won't move any of the negative input like up or left. This is the script I have:
var speed = 3.0;
var rotateSpeed = 3.0; var BulletPrefab:Transform; var rate : float = 2; private var rate_time : float; private var dead = false;
function OnControllerColliderHit(hit : ControllerColliderHit) { if(hit.gameObject.tag == "fallout") { dead = true; } } function Update () { var controller : CharacterController = GetComponent(CharacterController);
//Rotate around y - axis
transform.Rotate(0, Input.GetAxis ("2Horizontal") * rotateSpeed, 0);
// Move forward / backward
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis ("2Vertical");
controller.SimpleMove(forward * curSpeed);
if(Input.GetButtonDown("Fire1") && Time.time > rate_time)
{
var bullet = Instantiate(BulletPrefab, GameObject.Find("2spawnPoint").transform.position, Quaternion.identity);
bullet.gameObject.tag = "ememyProjectile";
bullet.rigidbody.AddForce(transform.forward * 3000);
}
if(dead)
{
transform.position = Vector3(11.77608,3.984688,105.742);
dead = false;
}
}
@script RequireComponent(CharacterController)
Your answer
![](https://koobas.hobune.stream/wayback/20220613063533im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
CharacterController and end of collision 2 Answers
Camera following two objects 0 Answers
Collision Detection with certain object using CharacterController(C#) 0 Answers
2D Game RigidBody Vs. Character Controller 2 Answers
Rigid body with moveDirection 0 Answers