Movement and Hitbox Tweaks, Jumping updated

main
thoopchuk26 4 years ago
parent a172910b57
commit 97045e4988

@ -101,12 +101,12 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
_Velocity: 0
_MaxVelocity: 3
_MaxVelocity: 6
_Acc: 0
_AccSpeed: 0.4
_MaxAcc: 1
_MinAcc: -1
_Deceleration: 2
_AccSpeed: 0.25
_MaxAcc: 2
_MinAcc: -2
_Deceleration: 0.4
jumpForce: 350
--- !u!114 &-5793387185563800375
MonoBehaviour:
@ -136,8 +136,8 @@ CapsuleCollider2D:
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_Size: {x: 9.75, y: 11.35}
m_Offset: {x: -0.06668711, y: 0.15004826}
m_Size: {x: 4.88177, y: 11.650097}
m_Direction: 0
--- !u!50 &4572441351392969366
Rigidbody2D:

@ -123,6 +123,71 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1001 &377944184
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 374150667840124763, guid: e9268c7f81b604f459302eb8b45a432e, type: 3}
propertyPath: m_Name
value: Player
objectReference: {fileID: 0}
- target: {fileID: 374150667840124766, guid: e9268c7f81b604f459302eb8b45a432e, type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: -2144373788310312413, guid: 1729f180fd26be543921d7aeaed5bddb, type: 3}
- target: {fileID: 374150667840124766, guid: e9268c7f81b604f459302eb8b45a432e, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 374150667840124767, guid: e9268c7f81b604f459302eb8b45a432e, type: 3}
propertyPath: m_RootOrder
value: 2
objectReference: {fileID: 0}
- target: {fileID: 374150667840124767, guid: e9268c7f81b604f459302eb8b45a432e, type: 3}
propertyPath: m_LocalPosition.x
value: -0.04
objectReference: {fileID: 0}
- target: {fileID: 374150667840124767, guid: e9268c7f81b604f459302eb8b45a432e, type: 3}
propertyPath: m_LocalPosition.y
value: 0.07
objectReference: {fileID: 0}
- target: {fileID: 374150667840124767, guid: e9268c7f81b604f459302eb8b45a432e, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 374150667840124767, guid: e9268c7f81b604f459302eb8b45a432e, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 374150667840124767, guid: e9268c7f81b604f459302eb8b45a432e, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 374150667840124767, guid: e9268c7f81b604f459302eb8b45a432e, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 374150667840124767, guid: e9268c7f81b604f459302eb8b45a432e, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 374150667840124767, guid: e9268c7f81b604f459302eb8b45a432e, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 374150667840124767, guid: e9268c7f81b604f459302eb8b45a432e, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 374150667840124767, guid: e9268c7f81b604f459302eb8b45a432e, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e9268c7f81b604f459302eb8b45a432e, type: 3}
--- !u!1 &962485059
GameObject:
m_ObjectHideFlags: 0
@ -204,7 +269,7 @@ Transform:
m_LocalScale: {x: 19.8608, y: 4.038, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!61 &962485062
BoxCollider2D:
@ -232,158 +297,6 @@ BoxCollider2D:
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0
--- !u!1 &1000257558
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1000257562}
- component: {fileID: 1000257561}
- component: {fileID: 1000257560}
- component: {fileID: 1000257559}
- component: {fileID: 1000257563}
m_Layer: 0
m_Name: Player
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1000257559
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1000257558}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ae152fc78d6362b4ea5f1111aad0b919, type: 3}
m_Name:
m_EditorClassIdentifier:
_Velocity: 0
_MaxVelocity: 6
_Acc: 0
_AccSpeed: 0.25
_MaxAcc: 2
_MinAcc: -2
_Deceleration: 0.4
jumpForce: 350
--- !u!50 &1000257560
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1000257558}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 1
m_Material: {fileID: 0}
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 0
--- !u!212 &1000257561
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1000257558}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 7482667652216324306, guid: db750325989564987a34393247d883b4, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!4 &1000257562
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1000257558}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!61 &1000257563
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1000257558}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 1, y: 1}
newSize: {x: 1, y: 1}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0
--- !u!1 &1041640411
GameObject:
m_ObjectHideFlags: 0

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b6fc70ea50160d842b9bed3c73d37210
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DoubleJumpPowerup : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter2D(Collider2D collision)
{
Debug.Log("DoubleJump Powerup Obtained");
GameManager.Instance.obtainedPowerups.Add(Powerup.DoubleJump);
GameManager.Instance.powerupStatus.Add(false);
Destroy(gameObject);
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e402d22de9c73d5458840496e2d7d97e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -18,7 +18,7 @@ public class GliderPowerupPickup : MonoBehaviour
private void OnTriggerEnter2D(Collider2D collision)
{
Debug.Log("Test");
Debug.Log("Glider Powerup Obtained");
GameManager.Instance.obtainedPowerups.Add(Powerup.Glider);
GameManager.Instance.powerupStatus.Add(false);
Destroy(gameObject);

@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HealthUpPowerup : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter2D(Collider2D collision)
{
Debug.Log("HealthUp Powerup Obtained");
GameManager.Instance.obtainedPowerups.Add(Powerup.HealthUp);
GameManager.Instance.powerupStatus.Add(false);
Destroy(gameObject);
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4ae43302a65924f4c8bc267861814d4d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
using System;
public enum Powerup
{
Glider,
DoubleJump,
HealthUp,
Shrink
}

@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShrinkPowerup : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter2D(Collider2D collision)
{
Debug.Log("Shrink Powerup Obtained");
GameManager.Instance.obtainedPowerups.Add(Powerup.Shrink);
GameManager.Instance.powerupStatus.Add(false);
Destroy(gameObject);
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2121bebb79696c742bd6ac9f9a701c81
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,5 +0,0 @@
using System;
public enum Powerup
{
Glider
}

@ -1,128 +1,131 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class movement : MonoBehaviour
{
private float horizontal, vertical;
private bool jumping = false;
private bool faceRight = true;
private Rigidbody2D rb2d;
private Animator animator;
public float _Velocity = 0.0f;
public float _MaxVelocity = 1.0f;
public float _Acc = 0.0f;
public float _AccSpeed = 0.1f;
public float _MaxAcc = 1.0f;
public float _MinAcc = -1.0f;
public float _Deceleration = 2f;
public float jumpForce = 350;
private bool isGrounded;
// Start is called before the first frame update
void Start()
{
rb2d = GetComponent<Rigidbody2D>();
animator = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
}
private void FixedUpdate()
{
horizontal = Input.GetAxisRaw("Horizontal");
vertical = Input.GetAxisRaw("Vertical");
animator.SetFloat("horizontal", horizontal);
if (horizontal < 0)
{
if (faceRight)
{
flip();
}
_Acc = 0;
_Acc -= _AccSpeed;
acceleration();
}
else if (horizontal > 0)
{
if (!faceRight)
{
flip();
}
_Acc = 0;
_Acc += _AccSpeed;
acceleration();
}
if (horizontal == 0)
{
deceleration();
}
rb2d.velocity = new Vector2(_Velocity, rb2d.velocity.y);
if (Input.GetKeyDown("space") && !jumping)
{
rb2d.velocity = new Vector2(rb2d.velocity.x, 0);
rb2d.AddForce(new Vector2(0, jumpForce));
jumping = true;
}
JumpAnimation();
}
private void acceleration()
{
if (_Acc > _MaxAcc)
_Acc = _MaxAcc;
else if (_Acc < _MinAcc)
_Acc = _MinAcc;
_Velocity += _Acc;
if (_Velocity > _MaxVelocity)
_Velocity = _MaxVelocity;
else if (_Velocity < -_MaxVelocity)
_Velocity = -_MaxVelocity;
}
private void deceleration()
{
if (_Velocity > 0)
{
_Velocity -= _Deceleration;
}
else if (_Velocity < 0)
{
_Velocity += _Deceleration;
}
if (_Velocity < _Deceleration && _Velocity > -_Deceleration)
{
_Velocity = 0;
}
}
private void flip()
{
faceRight = !faceRight;
Vector3 scaler = transform.localScale;
scaler.x *= -1;
transform.localScale = scaler;
}
private void OnCollisionEnter2D(Collision2D collision)
{
jumping = false;
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class movement : MonoBehaviour
{
private float horizontal, vertical;
private bool faceRight = true;
private Rigidbody2D rb2d;
private Animator animator;
public float _Velocity = 0.0f;
public float _MaxVelocity = 1.0f;
public float _Acc = 0.0f;
public float _AccSpeed = 0.1f;
public float _MaxAcc = 1.0f;
public float _MinAcc = -1.0f;
public float _Deceleration = 2f;
public float jumpForce = 350;
private float maxJumps = 1;
private float numJumps;
private bool isGrounded = true;
// Start is called before the first frame update
void Start()
{
rb2d = GetComponent<Rigidbody2D>();
numJumps = maxJumps;
animator = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown("space") && numJumps > 0)
{
rb2d.velocity = new Vector2(rb2d.velocity.x, 0);
rb2d.AddForce(new Vector2(0, jumpForce));
isGrounded = false;
numJumps -= 1;
}
}
private void FixedUpdate()
{
horizontal = Input.GetAxisRaw("Horizontal");
vertical = Input.GetAxisRaw("Vertical");
animator.SetFloat("horizontal", horizontal);
if (horizontal < 0)
{
if (faceRight)
{
flip();
}
_Acc = 0;
_Acc -= _AccSpeed;
acceleration();
}
else if (horizontal > 0)
{
if (!faceRight)
{
flip();
}
_Acc = 0;
_Acc += _AccSpeed;
acceleration();
}
if (horizontal == 0)
{
deceleration();
}
rb2d.velocity = new Vector2(_Velocity, rb2d.velocity.y);
JumpAnimation();
}
private void acceleration()
{
if (_Acc > _MaxAcc)
_Acc = _MaxAcc;
else if (_Acc < _MinAcc)
_Acc = _MinAcc;
_Velocity += _Acc;
if (_Velocity > _MaxVelocity)
_Velocity = _MaxVelocity;
else if (_Velocity < -_MaxVelocity)
_Velocity = -_MaxVelocity;
}
private void deceleration()
{
if (_Velocity > 0)
{
_Velocity -= _Deceleration;
}
else if (_Velocity < 0)
{
_Velocity += _Deceleration;
}
if (_Velocity < _Deceleration && _Velocity > -_Deceleration)
{
_Velocity = 0;
}
}
private void flip()
{
faceRight = !faceRight;
Vector3 scaler = transform.localScale;
scaler.x *= -1;
transform.localScale = scaler;
}
private void OnCollisionEnter2D(Collision2D collision)
{
numJumps = maxJumps;
isGrounded = true;
Debug.Log("Able to Jump");
}
private void JumpAnimation()
{
if (!isGrounded)
@ -135,5 +138,6 @@ public class movement : MonoBehaviour
animator.SetBool("isGrounded", true);
animator.SetFloat("velocityY", 0);
}
}
}
}
}

@ -6,34 +6,34 @@ EditorUserSettings:
serializedVersion: 4
m_ConfigSettings:
RecentlyUsedScenePath-0:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23620b1220f1a00637edea78fce9332b25
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23620c1336eff9002dece933e5a92f31352d1b
flags: 0
RecentlyUsedScenePath-1:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23620b1220f1a00637edea78fce9332b25
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621d1224e7f27a2decee22f0
flags: 0
RecentlyUsedScenePath-2:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23620b1220f1d23b37efa923e7ee2e26
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621b1226f6e50037d6e821ecf5742a323016f6
flags: 0
RecentlyUsedScenePath-3:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621d1224e7f27a2decee22f0
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a2362191c27ead43b1aedf425a7f234362820
flags: 0
RecentlyUsedScenePath-4:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621d1224e7f27a2decee22f0
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23620b1132eceb7414e7f133e5a92f31352d1b
flags: 0
RecentlyUsedScenePath-5:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a2362191c27ead43b1aedf425a7f234362820
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23620b1220f1d23b37efa923e7ee2e26
flags: 0
RecentlyUsedScenePath-6:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621b1226f6e50037d6e821ecf5742a323016f6
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621a0d3ae9e5740be1e238eca92f31352d1b
flags: 0
RecentlyUsedScenePath-7:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621a0d32f5ee7a2decee22f0
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
flags: 0
RecentlyUsedScenePath-8:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23620c1336eff9002dece933e5a92f31352d1b
value: 22424703114646680e0b0227036c6b1505032b292926237e38271427fb
flags: 0
RecentlyUsedScenePath-9:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621a0d3ae9e5740be1e238eca92f31352d1b
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621a0d32f5ee7a2decee22f0
flags: 0
vcSharedLogLevel:
value: 0d5e400f0650

Loading…
Cancel
Save