- Home /
The simplest way to display an image for a certain time?
Hello, I'm stuck for a day in my game. It's a fight to death multiplayer, everything is on it's place but I can't display who won.
public class PlayerController : MonoBehaviour { public Rigidbody player; public Rigidbody player2; public float forwardForce = 2000f; public float sideForce = 500f; public Quaternion originalRotationValue; float rotationResetSpeed = 1.0f; public static bool Playable; public Transform inGameCanvas; public Transform player1Wins; public Transform player2Wins; int hide = 0; // Use this for initialization public void Start () { originalRotationValue = transform.rotation;
}
// Update is called once per frame
public void FixedUpdate()
{
if (hide <= 0)
{
}
else
{
hide--;
}
//I got this but I don't know If it's going work
if (Playable) {
inGameCanvas.gameObject.SetActive(true);
if (Input.GetKey("right"))
{
player2.AddForce(sideForce * Time.deltaTime, 0, 0);
}
if (Input.GetKey("left"))
{
player2.AddForce(-sideForce * Time.deltaTime, 0, 0);
}
if (Input.GetKey("up"))
{
player2.AddForce(0, 0, sideForce * Time.deltaTime);
}
if (Input.GetKey("down"))
{
player2.AddForce(0, 0, -sideForce * Time.deltaTime);
}
if (Input.GetKey("d"))
{
player.AddForce(sideForce * Time.deltaTime, 0, 0);
}
if (Input.GetKey("a"))
{
player.AddForce(-sideForce * Time.deltaTime, 0, 0);
}
if (Input.GetKey("w"))
{
player.AddForce(0, 0, sideForce * Time.deltaTime);
}
if (Input.GetKey("s"))
{
player.AddForce(0, 0, -sideForce * Time.deltaTime);
}
if (player.position.y < -10 || player2.position.y < -10) {
if (player.position.y < -10)
{
player1Wins.gameObject.SetActive(true);
}
if (player2.position.y < -10)
{
player2Wins.gameObject.SetActive(true);
}
player.transform.position = new Vector3(-3, 1.15f, 0.5f);
player2.transform.position = new Vector3(3, 1.15f, 0.5f);
player2.velocity = Vector3.zero;
player2.angularVelocity = Vector3.zero;
player.velocity = Vector3.zero;
player.angularVelocity = Vector3.zero;
player2.transform.rotation = Quaternion.Slerp(transform.rotation, originalRotationValue, Time.time * rotationResetSpeed);
player.transform.rotation = Quaternion.Slerp(transform.rotation, originalRotationValue, Time.time * rotationResetSpeed);
hide = 150;
}
}
}
}
Your answer
Follow this Question
Related Questions
Game Which Adapts Via Real-Life Date & Time 0 Answers
Reading an event log file 0 Answers
Best way of handling time events based on global time? 0 Answers
How to work a real life timer? 2 Answers