mirror of
https://github.com/ConjureETS/Labo_2_equ_2_a15.git
synced 2026-03-24 01:21:07 +00:00
Fixed jump and wall sticking (not perfect)
This commit is contained in:
parent
2348007017
commit
8447b8123a
@ -10,7 +10,7 @@ GameObject:
|
|||||||
- 4: {fileID: 417046}
|
- 4: {fileID: 417046}
|
||||||
- 212: {fileID: 21285978}
|
- 212: {fileID: 21285978}
|
||||||
- 61: {fileID: 6117568}
|
- 61: {fileID: 6117568}
|
||||||
m_Layer: 0
|
m_Layer: 8
|
||||||
m_Name: Ground
|
m_Name: Ground
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
@ -74,7 +74,11 @@ Prefab:
|
|||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Modification:
|
m_Modification:
|
||||||
m_TransformParent: {fileID: 0}
|
m_TransformParent: {fileID: 0}
|
||||||
m_Modifications: []
|
m_Modifications:
|
||||||
|
- target: {fileID: 0}
|
||||||
|
propertyPath: m_Layer
|
||||||
|
value: 8
|
||||||
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_ParentPrefab: {fileID: 0}
|
m_ParentPrefab: {fileID: 0}
|
||||||
m_RootGameObject: {fileID: 167312}
|
m_RootGameObject: {fileID: 167312}
|
||||||
|
|||||||
@ -1,5 +1,20 @@
|
|||||||
%YAML 1.1
|
%YAML 1.1
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &137562
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
serializedVersion: 4
|
||||||
|
m_Component:
|
||||||
|
- 4: {fileID: 430186}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: GroundCheck
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 5132851093641282708, guid: 0000000000000000d000000000000000, type: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
--- !u!1 &177424
|
--- !u!1 &177424
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -8,8 +23,8 @@ GameObject:
|
|||||||
serializedVersion: 4
|
serializedVersion: 4
|
||||||
m_Component:
|
m_Component:
|
||||||
- 4: {fileID: 437628}
|
- 4: {fileID: 437628}
|
||||||
m_Layer: 8
|
m_Layer: 0
|
||||||
m_Name: GroundCheck
|
m_Name: WallCheck
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 5132851093641282708, guid: 0000000000000000d000000000000000, type: 0}
|
m_Icon: {fileID: 5132851093641282708, guid: 0000000000000000d000000000000000, type: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
@ -32,13 +47,25 @@ GameObject:
|
|||||||
- 114: {fileID: 11472154}
|
- 114: {fileID: 11472154}
|
||||||
- 114: {fileID: 11478382}
|
- 114: {fileID: 11478382}
|
||||||
- 114: {fileID: 11485758}
|
- 114: {fileID: 11485758}
|
||||||
m_Layer: 8
|
m_Layer: 0
|
||||||
m_Name: Player
|
m_Name: Player
|
||||||
m_TagString: Player
|
m_TagString: Player
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 1
|
||||||
|
--- !u!4 &430186
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
m_GameObject: {fileID: 137562}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: -.116999999, z: 0}
|
||||||
|
m_LocalScale: {x: .922599614, y: .922599435, z: .922599435}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 462904}
|
||||||
|
m_RootOrder: 0
|
||||||
--- !u!4 &437628
|
--- !u!4 &437628
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 1
|
m_ObjectHideFlags: 1
|
||||||
@ -46,11 +73,11 @@ Transform:
|
|||||||
m_PrefabInternal: {fileID: 100100000}
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
m_GameObject: {fileID: 177424}
|
m_GameObject: {fileID: 177424}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: -.116999999, z: 0}
|
m_LocalPosition: {x: .0854000002, y: .0140000004, z: 0}
|
||||||
m_LocalScale: {x: .922599614, y: .922599435, z: .922599435}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 462904}
|
m_Father: {fileID: 462904}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 1
|
||||||
--- !u!4 &462904
|
--- !u!4 &462904
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 1
|
m_ObjectHideFlags: 1
|
||||||
@ -61,6 +88,7 @@ Transform:
|
|||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
|
- {fileID: 430186}
|
||||||
- {fileID: 437628}
|
- {fileID: 437628}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
@ -137,11 +165,14 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
maxSpeed: 2
|
maxSpeed: 2
|
||||||
grounded: 1
|
grounded: 1
|
||||||
groundCheck: {fileID: 437628}
|
groundCheck: {fileID: 430186}
|
||||||
|
wallCheck: {fileID: 437628}
|
||||||
|
groundRadius: .00999999978
|
||||||
|
wallCheckRadius: .00999999978
|
||||||
ground:
|
ground:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Bits: 4294967039
|
m_Bits: 256
|
||||||
jumpForce: 35
|
jumpForce: 175
|
||||||
--- !u!114 &11472154
|
--- !u!114 &11472154
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 1
|
m_ObjectHideFlags: 1
|
||||||
@ -217,6 +248,22 @@ Prefab:
|
|||||||
propertyPath: bomb
|
propertyPath: bomb
|
||||||
value:
|
value:
|
||||||
objectReference: {fileID: 172872, guid: c08879c52df47d54aa37a52cd902cc42, type: 2}
|
objectReference: {fileID: 172872, guid: c08879c52df47d54aa37a52cd902cc42, type: 2}
|
||||||
|
- target: {fileID: 0}
|
||||||
|
propertyPath: jumpForce
|
||||||
|
value: 175
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 0}
|
||||||
|
propertyPath: ground.m_Bits
|
||||||
|
value: 256
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 0}
|
||||||
|
propertyPath: m_Layer
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 0}
|
||||||
|
propertyPath: m_Interpolate
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_ParentPrefab: {fileID: 0}
|
m_ParentPrefab: {fileID: 0}
|
||||||
m_RootGameObject: {fileID: 197158}
|
m_RootGameObject: {fileID: 197158}
|
||||||
|
|||||||
@ -112,6 +112,7 @@ Transform:
|
|||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 1903720196}
|
- {fileID: 1903720196}
|
||||||
- {fileID: 1747148540}
|
- {fileID: 1747148540}
|
||||||
|
- {fileID: 1077673240}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 3
|
m_RootOrder: 3
|
||||||
--- !u!1 &328141749
|
--- !u!1 &328141749
|
||||||
@ -163,7 +164,7 @@ Transform:
|
|||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_GameObject: {fileID: 328141749}
|
m_GameObject: {fileID: 328141749}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 6.75, y: -.280000001, z: 0}
|
m_LocalPosition: {x: 6.89699984, y: -.298000008, z: 0}
|
||||||
m_LocalScale: {x: 1.66666663, y: 1.66666663, z: 1}
|
m_LocalScale: {x: 1.66666663, y: 1.66666663, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 645992365}
|
m_Father: {fileID: 645992365}
|
||||||
@ -245,41 +246,45 @@ Prefab:
|
|||||||
m_Modification:
|
m_Modification:
|
||||||
m_TransformParent: {fileID: 0}
|
m_TransformParent: {fileID: 0}
|
||||||
m_Modifications:
|
m_Modifications:
|
||||||
- target: {fileID: 434640, guid: b7819e17682d74b45a71d6831a413e0b, type: 2}
|
- target: {fileID: 462904, guid: b7819e17682d74b45a71d6831a413e0b, type: 2}
|
||||||
propertyPath: m_LocalPosition.x
|
propertyPath: m_LocalPosition.x
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 434640, guid: b7819e17682d74b45a71d6831a413e0b, type: 2}
|
- target: {fileID: 462904, guid: b7819e17682d74b45a71d6831a413e0b, type: 2}
|
||||||
propertyPath: m_LocalPosition.y
|
propertyPath: m_LocalPosition.y
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 434640, guid: b7819e17682d74b45a71d6831a413e0b, type: 2}
|
- target: {fileID: 462904, guid: b7819e17682d74b45a71d6831a413e0b, type: 2}
|
||||||
propertyPath: m_LocalPosition.z
|
propertyPath: m_LocalPosition.z
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 434640, guid: b7819e17682d74b45a71d6831a413e0b, type: 2}
|
- target: {fileID: 462904, guid: b7819e17682d74b45a71d6831a413e0b, type: 2}
|
||||||
propertyPath: m_LocalRotation.x
|
propertyPath: m_LocalRotation.x
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 434640, guid: b7819e17682d74b45a71d6831a413e0b, type: 2}
|
- target: {fileID: 462904, guid: b7819e17682d74b45a71d6831a413e0b, type: 2}
|
||||||
propertyPath: m_LocalRotation.y
|
propertyPath: m_LocalRotation.y
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 434640, guid: b7819e17682d74b45a71d6831a413e0b, type: 2}
|
- target: {fileID: 462904, guid: b7819e17682d74b45a71d6831a413e0b, type: 2}
|
||||||
propertyPath: m_LocalRotation.z
|
propertyPath: m_LocalRotation.z
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 434640, guid: b7819e17682d74b45a71d6831a413e0b, type: 2}
|
- target: {fileID: 462904, guid: b7819e17682d74b45a71d6831a413e0b, type: 2}
|
||||||
propertyPath: m_LocalRotation.w
|
propertyPath: m_LocalRotation.w
|
||||||
value: 1
|
value: 1
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 434640, guid: b7819e17682d74b45a71d6831a413e0b, type: 2}
|
- target: {fileID: 462904, guid: b7819e17682d74b45a71d6831a413e0b, type: 2}
|
||||||
propertyPath: m_RootOrder
|
propertyPath: m_RootOrder
|
||||||
value: 2
|
value: 2
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_ParentPrefab: {fileID: 100100000, guid: b7819e17682d74b45a71d6831a413e0b, type: 2}
|
m_ParentPrefab: {fileID: 100100000, guid: b7819e17682d74b45a71d6831a413e0b, type: 2}
|
||||||
m_IsPrefabParent: 0
|
m_IsPrefabParent: 0
|
||||||
|
--- !u!4 &1077673240 stripped
|
||||||
|
Transform:
|
||||||
|
m_PrefabParentObject: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2}
|
||||||
|
m_PrefabInternal: {fileID: 1931418958}
|
||||||
--- !u!1 &1449410197
|
--- !u!1 &1449410197
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -387,6 +392,52 @@ Transform:
|
|||||||
Transform:
|
Transform:
|
||||||
m_PrefabParentObject: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2}
|
m_PrefabParentObject: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2}
|
||||||
m_PrefabInternal: {fileID: 849444827}
|
m_PrefabInternal: {fileID: 849444827}
|
||||||
|
--- !u!1001 &1931418958
|
||||||
|
Prefab:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Modification:
|
||||||
|
m_TransformParent: {fileID: 42885627}
|
||||||
|
m_Modifications:
|
||||||
|
- target: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2}
|
||||||
|
propertyPath: m_LocalPosition.x
|
||||||
|
value: -1.29499996
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2}
|
||||||
|
propertyPath: m_LocalPosition.y
|
||||||
|
value: .768999994
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2}
|
||||||
|
propertyPath: m_LocalPosition.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2}
|
||||||
|
propertyPath: m_LocalRotation.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2}
|
||||||
|
propertyPath: m_LocalRotation.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2}
|
||||||
|
propertyPath: m_LocalRotation.z
|
||||||
|
value: .707106829
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2}
|
||||||
|
propertyPath: m_LocalRotation.w
|
||||||
|
value: .707106709
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2}
|
||||||
|
propertyPath: m_RootOrder
|
||||||
|
value: 2
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 167312, guid: 6a21797441b99c942915e70c461edf77, type: 2}
|
||||||
|
propertyPath: m_Name
|
||||||
|
value: Ground
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
m_RemovedComponents: []
|
||||||
|
m_ParentPrefab: {fileID: 100100000, guid: 6a21797441b99c942915e70c461edf77, type: 2}
|
||||||
|
m_IsPrefabParent: 0
|
||||||
--- !u!1001 &2106831666
|
--- !u!1001 &2106831666
|
||||||
Prefab:
|
Prefab:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -9,7 +9,9 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
// Jump Stuff
|
// Jump Stuff
|
||||||
public bool grounded = true;
|
public bool grounded = true;
|
||||||
public Transform groundCheck;
|
public Transform groundCheck;
|
||||||
private float groundRadius = 0.1f;
|
public Transform wallCheck;
|
||||||
|
public float groundRadius = 0.01f;
|
||||||
|
public float wallCheckRadius = 0.01f;
|
||||||
public LayerMask ground;
|
public LayerMask ground;
|
||||||
public float jumpForce = 7.0f;
|
public float jumpForce = 7.0f;
|
||||||
|
|
||||||
@ -28,7 +30,7 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
if (grounded && Input.GetAxis("Vertical") > 0.0f)
|
if (grounded && Input.GetButtonDown("Jump"))
|
||||||
{
|
{
|
||||||
anim.SetBool("Ground", false);
|
anim.SetBool("Ground", false);
|
||||||
rb.AddForce(new Vector2(0, jumpForce));
|
rb.AddForce(new Vector2(0, jumpForce));
|
||||||
@ -53,6 +55,11 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
anim.SetFloat("vSpeed", rb.velocity.y);
|
anim.SetFloat("vSpeed", rb.velocity.y);
|
||||||
|
|
||||||
float xMove = Input.GetAxis("Horizontal");
|
float xMove = Input.GetAxis("Horizontal");
|
||||||
|
if(Physics2D.OverlapCircle(wallCheck.position, wallCheckRadius, ground))
|
||||||
|
{
|
||||||
|
if((xMove > 0 && facingRight) || (xMove < 0 && !facingRight))
|
||||||
|
xMove = 0;
|
||||||
|
}
|
||||||
rb.velocity = new Vector2(xMove * maxSpeed, rb.velocity.y);
|
rb.velocity = new Vector2(xMove * maxSpeed, rb.velocity.y);
|
||||||
|
|
||||||
if ((xMove < 0 && facingRight) || (xMove > 0 && !facingRight))
|
if ((xMove < 0 && facingRight) || (xMove > 0 && !facingRight))
|
||||||
|
|||||||
@ -15,7 +15,7 @@ TagManager:
|
|||||||
- UI
|
- UI
|
||||||
-
|
-
|
||||||
-
|
-
|
||||||
-
|
- Ground
|
||||||
-
|
-
|
||||||
-
|
-
|
||||||
-
|
-
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user