Fixed switching
This commit is contained in:
@@ -3,7 +3,7 @@ using UnityEngine.Events;
|
||||
|
||||
public class CharacterController2D : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float m_JumpForce = 400f; // Amount of force added when the player jumps.
|
||||
public float m_JumpForce = 400f; // Amount of force added when the player jumps.
|
||||
[Range(0, .3f)] [SerializeField] private float m_MovementSmoothing = .05f; // How much to smooth out the movement
|
||||
[SerializeField] private bool m_AirControl = false; // Whether or not a player can steer while jumping;
|
||||
[SerializeField] private LayerMask m_WhatIsGround; // A mask determining what is ground to the character
|
||||
|
@@ -12,6 +12,7 @@ public class PlayerControls : MonoBehaviour
|
||||
public CharacterController2D controller;
|
||||
public float runspeed = 40f;
|
||||
float horizonatalaxis = 0f;
|
||||
|
||||
bool jumping = false;
|
||||
bool switchy = false;
|
||||
|
||||
@@ -30,16 +31,19 @@ public class PlayerControls : MonoBehaviour
|
||||
|
||||
if(Input.GetButtonDown("Switch")) {
|
||||
switchy = !switchy;
|
||||
if (switchy){
|
||||
sprite.flipY = true;
|
||||
rigidbody.sharedMaterial = top;
|
||||
controller.m_JumpForce = controller.m_JumpForce * 1.2f;
|
||||
}
|
||||
else {
|
||||
sprite.flipY = false;
|
||||
rigidbody.sharedMaterial = bottom;
|
||||
controller.m_JumpForce = controller.m_JumpForce * 0.8f;
|
||||
}
|
||||
}
|
||||
|
||||
if (switchy){
|
||||
sprite.flipY = true;
|
||||
rigidbody.sharedMaterial = top;
|
||||
}
|
||||
else {
|
||||
sprite.flipY = false;
|
||||
rigidbody.sharedMaterial = bottom;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void FixedUpdate(){
|
||||
|
Reference in New Issue
Block a user