private void Start()
    {
        DontDestroyOnLoad(gameObject);

        PlayerReadyIndicator = Instantiate(PlayerReadyIndicatorPrefab);
        PlayerReadyIndicator.GetComponent <PlayerReadyIndicatorController>().AttachedPlayer = this;

        de  = GetComponentInChildren <DashEffect>();
        gc  = GetComponentInChildren <GravityChange>();
        dth = GetComponentInChildren <deatheffect>();

        if (GameManager.Instance.OnPlayerJoin != null)
        {
            GameManager.Instance.OnPlayerJoin(this);
        }

        ControlledPlayer.NumLives = GameRoundSettingsController.Instance.NumLivesPerRound;

        StartCoroutine(AttachInputDeviceToPlayer());
        LevelManager.Instance.SpawnPlayer(this);
    }
Example #2
0
 void FixedUpdate()
 {
     switch (CurrentGravityChange) {
         case GravityChange.X:
             StartCoroutine(RotateMe(new Vector3(180f, 0f, 0f), _gravityRotationModifier));
             CurrentGravityChange = GravityChange.None;
             break;
         case GravityChange.nX:
             StartCoroutine(RotateMe(new Vector3(0f, 0f, 0f), _gravityRotationModifier));
             CurrentGravityChange = GravityChange.None;
             break;
         case GravityChange.Y:
             StartCoroutine(RotateMe(new Vector3(0f, 0f, -90f), _gravityRotationModifier));
             CurrentGravityChange = GravityChange.None;
             break;
         case GravityChange.nY:
             StartCoroutine(RotateMe(new Vector3(0f, 0f, 90f), _gravityRotationModifier));
             CurrentGravityChange = GravityChange.None;
             break;
         default:
             break;
     }
     float steer = Input.GetAxis("Horizontal");
     if (SkateboardPhysics.IsGrounded() && Mathf.Abs(steer) > 0.1f) {
         Quaternion q = Quaternion.AngleAxis(_rotationModifier * steer, Skateboard.transform.up) * Skateboard.transform.rotation;
         Skateboard.MoveRotation(q);
         float mag = Skateboard.velocity.magnitude;
         if (SkateboardPhysics.Switch) {
             Skateboard.velocity = -Skateboard.transform.forward * mag * 1f;
         } else {
             Skateboard.velocity = Skateboard.transform.forward * mag * 1f;
         }
         // Skateboard.AddRelativeTorque(Vector3.up * steer * _rotationModifier * Time.deltaTime);
     }
 }
Example #3
0
 private void Start()
 {
     pm = GetComponent <PlayerMovement>();
     gc = GetComponent <GravityChange>();
 }