Rework movement system to not directly write velocity
This commit is contained in:
@@ -241,7 +241,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: -4152331571693237436, guid: e05928a0d673caf999d31b31b994a112, type: 3}
|
- target: {fileID: -4152331571693237436, guid: e05928a0d673caf999d31b31b994a112, type: 3}
|
||||||
propertyPath: m_LinearDamping
|
propertyPath: m_LinearDamping
|
||||||
value: 0
|
value: 15
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: -4152331571693237436, guid: e05928a0d673caf999d31b31b994a112, type: 3}
|
- target: {fileID: -4152331571693237436, guid: e05928a0d673caf999d31b31b994a112, type: 3}
|
||||||
propertyPath: m_CollisionDetection
|
propertyPath: m_CollisionDetection
|
||||||
@@ -315,6 +315,10 @@ PrefabInstance:
|
|||||||
propertyPath: m_RenderPostProcessing
|
propertyPath: m_RenderPostProcessing
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 6118034672792182209, guid: e05928a0d673caf999d31b31b994a112, type: 3}
|
||||||
|
propertyPath: dashDistance
|
||||||
|
value: 1000
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 6118034672792182209, guid: e05928a0d673caf999d31b31b994a112, type: 3}
|
- target: {fileID: 6118034672792182209, guid: e05928a0d673caf999d31b31b994a112, type: 3}
|
||||||
propertyPath: attackCooldownSeconds
|
propertyPath: attackCooldownSeconds
|
||||||
value: 3
|
value: 3
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ public class Teo : MonoBehaviour
|
|||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update() {
|
void Update() {
|
||||||
// Move player
|
// Move player
|
||||||
controller.linearVelocity = new Vector2 (
|
controller.AddRelativeForce (new Vector2 (
|
||||||
Input.GetAxis("Horizontal"),
|
Input.GetAxis("Horizontal"),
|
||||||
Input.GetAxis("Vertical")
|
Input.GetAxis("Vertical")
|
||||||
).normalized * moveSpeed + dashVelocity;
|
).normalized * moveSpeed);
|
||||||
// Attack on click if not on cooldown
|
// Attack on click if not on cooldown
|
||||||
if (Input.GetMouseButtonDown(0)) {
|
if (Input.GetMouseButtonDown(0)) {
|
||||||
Attack();
|
Attack();
|
||||||
@@ -60,11 +60,18 @@ public class Teo : MonoBehaviour
|
|||||||
}
|
}
|
||||||
void Dash() {
|
void Dash() {
|
||||||
if (Time.fixedTime-lastDashTime < dashCooldownSeconds) return;
|
if (Time.fixedTime-lastDashTime < dashCooldownSeconds) return;
|
||||||
|
BoxCollider2D collider = GetComponent<BoxCollider2D>();
|
||||||
lastDashTime = Time.fixedTime;
|
lastDashTime = Time.fixedTime;
|
||||||
transform.position += new Vector3(
|
collider.enabled = false;
|
||||||
|
controller.linearDamping = 0;
|
||||||
|
controller.AddRelativeForce (new Vector2(
|
||||||
Input.mousePosition.x - Screen.width/2,
|
Input.mousePosition.x - Screen.width/2,
|
||||||
Input.mousePosition.y - Screen.height/2,
|
Input.mousePosition.y - Screen.height/2
|
||||||
0
|
).normalized * dashDistance);
|
||||||
).normalized * dashDistance;
|
Debug.Log("before");
|
||||||
|
new WaitForSeconds(2F);
|
||||||
|
Debug.Log("after");
|
||||||
|
controller.linearDamping = 15;
|
||||||
|
collider.enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user