void FixedUpdate() { var velocity = SimulationSettings.PlayerAcceleration; var joystick = PlayerInputReader.Data.joystick; space = joystick.space; if (joystick.shift) { velocity = velocity * 3; } if (!DeathWriter.Data.death) { rigidbody.transform.Translate(0f, 0f, joystick.yAxis * Time.deltaTime * velocity); rigidbody.transform.Rotate(0, joystick.xAxis * 150 * Time.deltaTime, 0); } else { rigidbody.MovePosition(new Vector3(0f, 1f, 0f)); var update2 = new Death.Update(); update2.SetDeath(false); DeathWriter.Send(update2); } var pos = rigidbody.position; var positionUpdate = new Position.Update() .SetCoords(new Coordinates(pos.x, pos.y, pos.z)); PositionWriter.Send(positionUpdate); var rotationUpdate = new Rotation.Update() .SetRotation(rigidbody.rotation.ToNativeQuaternion()); RotationWriter.Send(rotationUpdate); }
void OnTriggerStay(Collider other) { if (other != null && other.gameObject.tag == "Player" && other.gameObject.GetComponent <PlayerMover>().space&& time <= Time.time && other is CapsuleCollider) { float newHealth = HealthWriter.Data.health - 25f; time = Time.time + 1; if (newHealth <= 0) { var update = new Health.Update(); update.SetHealth(100f); HealthWriter.Send(update); other.gameObject.GetComponent <ScoresPlayer> ().addScores(25f); GetComponent <ScoresPlayer> ().reset(); rigidbody.MovePosition(new Vector3(0f, 1f, 0f)); var pos = rigidbody.position; var positionUpdate = new Position.Update() .SetCoords(new Coordinates(pos.x, pos.y, pos.z)); PositionWriter.Send(positionUpdate); var update2 = new Death.Update(); update2.SetDeath(true); DeathWriter.Send(update2); } else { var update = new Health.Update(); update.SetHealth(newHealth); HealthWriter.Send(update); other.gameObject.GetComponent <ScoresPlayer> ().addScores(25f); } } }