Added switch to player

This commit is contained in:
Bruno Rybársky 2021-07-20 18:04:44 +02:00
parent 7886a53c70
commit 0defb6f05e
6 changed files with 66 additions and 14 deletions

@ -8,4 +8,4 @@ PhysicsMaterial2D:
m_PrefabAsset: {fileID: 0}
m_Name: Slippery
friction: 0
bounciness: 0
bounciness: 1

@ -0,0 +1,11 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!62 &6200000
PhysicsMaterial2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: XNSlippery
friction: 1
bounciness: 0

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2c0538ecede9d3b43867ca45f72ba04b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 6200000
userData:
assetBundleName:
assetBundleVariant:

@ -291,9 +291,9 @@ GameObject:
m_Component:
- component: {fileID: 1174924377}
- component: {fileID: 1174924376}
- component: {fileID: 1174924375}
- component: {fileID: 1174924384}
- component: {fileID: 1174924383}
- component: {fileID: 1174924375}
- component: {fileID: 1174924382}
- component: {fileID: 1174924381}
- component: {fileID: 1174924380}
@ -401,7 +401,7 @@ CapsuleCollider2D:
m_GameObject: {fileID: 1174924374}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_Material: {fileID: 6200000, guid: 1431532fb1c75214a9a8c9b1199fe80b, type: 2}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
@ -417,7 +417,7 @@ CircleCollider2D:
m_GameObject: {fileID: 1174924374}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_Material: {fileID: 6200000, guid: 2c0538ecede9d3b43867ca45f72ba04b, type: 2}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
@ -433,7 +433,7 @@ CircleCollider2D:
m_GameObject: {fileID: 1174924374}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_Material: {fileID: 6200000, guid: 2c0538ecede9d3b43867ca45f72ba04b, type: 2}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
@ -449,7 +449,7 @@ CircleCollider2D:
m_GameObject: {fileID: 1174924374}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_Material: {fileID: 6200000, guid: 2c0538ecede9d3b43867ca45f72ba04b, type: 2}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
@ -472,9 +472,9 @@ Rigidbody2D:
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 4
m_Material: {fileID: 6200000, guid: 1431532fb1c75214a9a8c9b1199fe80b, type: 2}
m_Material: {fileID: 6200000, guid: 2c0538ecede9d3b43867ca45f72ba04b, type: 2}
m_Interpolate: 0
m_SleepingMode: 1
m_SleepingMode: 0
m_CollisionDetection: 1
m_Constraints: 4
--- !u!114 &1174924383
@ -490,7 +490,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_JumpForce: 700
m_CrouchSpeed: 0.36
m_CrouchSpeed: 1
m_MovementSmoothing: 0.05
m_AirControl: 1
m_WhatIsGround:
@ -498,7 +498,7 @@ MonoBehaviour:
m_Bits: 8
m_GroundCheck: {fileID: 1880458412}
m_CeilingCheck: {fileID: 599368085}
m_CrouchDisableCollider: {fileID: 1174924378}
m_CrouchDisableCollider: {fileID: 0}
OnLandEvent:
m_PersistentCalls:
m_Calls: []
@ -530,6 +530,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
animator: {fileID: 1174924375}
top: {fileID: 6200000, guid: 1431532fb1c75214a9a8c9b1199fe80b, type: 2}
rigidbody: {fileID: 1174924382}
bottom: {fileID: 6200000, guid: 2c0538ecede9d3b43867ca45f72ba04b, type: 2}
controller: {fileID: 1174924383}
runspeed: 40
--- !u!1 &1880458411
@ -662,7 +665,7 @@ Rigidbody2D:
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 1
m_Material: {fileID: 6200000, guid: 1431532fb1c75214a9a8c9b1199fe80b, type: 2}
m_Material: {fileID: 6200000, guid: 2c0538ecede9d3b43867ca45f72ba04b, type: 2}
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
@ -676,7 +679,7 @@ BoxCollider2D:
m_GameObject: {fileID: 2103537544}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 6200000, guid: 1431532fb1c75214a9a8c9b1199fe80b, type: 2}
m_Material: {fileID: 6200000, guid: 2c0538ecede9d3b43867ca45f72ba04b, type: 2}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0

@ -5,11 +5,16 @@ using UnityEngine;
public class PlayerControls : MonoBehaviour
{
public Animator animator;
public PhysicsMaterial2D top;
public Rigidbody2D rigidbody;
public PhysicsMaterial2D bottom;
public CharacterController2D controller;
public float runspeed = 40f;
float horizonatalaxis = 0f;
bool jumping = false;
bool crouching = false;
bool switchy = false;
void Start()
{
@ -23,14 +28,23 @@ public class PlayerControls : MonoBehaviour
jumping = Input.GetButton("Jump") || Input.GetAxisRaw("Vertical") > 0;
crouching = Input.GetButton("Crouch") || Input.GetAxisRaw("Vertical") < 0;
animator.SetFloat("Horizontal_speed", horizonatalaxis);
switchy = Input.GetButton("Switch");
if (switchy){
transform.rotation = new Quaternion(0f, 0f, 180f, 0f);
rigidbody.sharedMaterial = top;
}
else {
transform.rotation = new Quaternion(0f, 0f, 0f, 0f);
rigidbody.sharedMaterial = bottom;
}
}
public void crouchingx(bool stat){
animator.SetBool("Crouching", stat);
//animator.SetBool("Crouching", stat);
}
void FixedUpdate(){
controller.Move(horizonatalaxis * runspeed * Time.fixedDeltaTime, crouching, jumping);
controller.Move(horizonatalaxis * runspeed * Time.fixedDeltaTime, false, jumping);
}
}

@ -69,6 +69,22 @@ InputManager:
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Switch
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: e
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Mouse X
descriptiveName: