Fixed throwing on ground
This commit is contained in:
parent
c07aa285c8
commit
d57eab3e92
@ -193,6 +193,8 @@ MonoBehaviour:
|
|||||||
target: {fileID: 0}
|
target: {fileID: 0}
|
||||||
halo: {fileID: 160873202674104038}
|
halo: {fileID: 160873202674104038}
|
||||||
AIStats: {fileID: 11400000, guid: 9d8a9a664d932d0498d5eca7607eeb53, type: 2}
|
AIStats: {fileID: 11400000, guid: 9d8a9a664d932d0498d5eca7607eeb53, type: 2}
|
||||||
|
thrownFromSafeZone: 0
|
||||||
|
thrownTargetPosition: {x: 0, y: 0, z: 0}
|
||||||
--- !u!50 &1427479462206541758
|
--- !u!50 &1427479462206541758
|
||||||
Rigidbody2D:
|
Rigidbody2D:
|
||||||
serializedVersion: 4
|
serializedVersion: 4
|
||||||
@ -206,7 +208,7 @@ Rigidbody2D:
|
|||||||
m_UseFullKinematicContacts: 0
|
m_UseFullKinematicContacts: 0
|
||||||
m_UseAutoMass: 0
|
m_UseAutoMass: 0
|
||||||
m_Mass: 1
|
m_Mass: 1
|
||||||
m_LinearDrag: 0
|
m_LinearDrag: 1
|
||||||
m_AngularDrag: 0.05
|
m_AngularDrag: 0.05
|
||||||
m_GravityScale: 0
|
m_GravityScale: 0
|
||||||
m_Material: {fileID: 6200000, guid: 72c8b57001d325c418a78771641a077f, type: 2}
|
m_Material: {fileID: 6200000, guid: 72c8b57001d325c418a78771641a077f, type: 2}
|
||||||
|
|||||||
@ -630,10 +630,6 @@ PrefabInstance:
|
|||||||
propertyPath: m_LocalEulerAnglesHint.z
|
propertyPath: m_LocalEulerAnglesHint.z
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1214567908930553595, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
|
||||||
propertyPath: m_SortingOrder
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1967503440015794769, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1967503440015794769, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: gameFlowManager
|
propertyPath: gameFlowManager
|
||||||
value:
|
value:
|
||||||
|
|||||||
@ -51,3 +51,5 @@ MonoBehaviour:
|
|||||||
m_PostInfinity: 2
|
m_PostInfinity: 2
|
||||||
m_RotationOrder: 4
|
m_RotationOrder: 4
|
||||||
<ThrownDurationPerMeter>k__BackingField: 0.15
|
<ThrownDurationPerMeter>k__BackingField: 0.15
|
||||||
|
<MinVelocityWhenThrown>k__BackingField: 2
|
||||||
|
throwForce: 5
|
||||||
|
|||||||
@ -16,4 +16,10 @@ public class AIStats : ScriptableObject {
|
|||||||
|
|
||||||
[field: SerializeField]
|
[field: SerializeField]
|
||||||
public float ThrownDurationPerMeter { get; private set; }
|
public float ThrownDurationPerMeter { get; private set; }
|
||||||
|
|
||||||
|
[field: SerializeField] [field: Min(0f)]
|
||||||
|
public float MinVelocityWhenThrown { get; private set; } = 5f;
|
||||||
|
|
||||||
|
[field: SerializeField] [field: Min(0f)]
|
||||||
|
public float throwForce = 3f;
|
||||||
}
|
}
|
||||||
@ -9,9 +9,6 @@ public class Entity : MonoBehaviour {
|
|||||||
[Required]
|
[Required]
|
||||||
public GameFlowManager gameFlowManager = null!;
|
public GameFlowManager gameFlowManager = null!;
|
||||||
|
|
||||||
[field: SerializeField]
|
|
||||||
[field: Required]
|
|
||||||
public EntityStats stats { get; private set; }
|
|
||||||
[field: SerializeField] public float Health { get; private set; }
|
[field: SerializeField] public float Health { get; private set; }
|
||||||
[Min(10f)]
|
[Min(10f)]
|
||||||
protected float initialHealth;
|
protected float initialHealth;
|
||||||
@ -48,13 +45,7 @@ public class Entity : MonoBehaviour {
|
|||||||
|
|
||||||
protected virtual void Update() { }
|
protected virtual void Update() { }
|
||||||
|
|
||||||
protected virtual void FixedUpdate() {
|
protected virtual void FixedUpdate() {}
|
||||||
//TODO sqrMagnitude?
|
|
||||||
if (beingPushed && rb.velocity.magnitude < stats.MinVelocityWhenThrown) {
|
|
||||||
rb.velocity = Vector2.zero;
|
|
||||||
beingPushed = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void Attack() {
|
protected virtual void Attack() {
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class EntityStats {
|
|
||||||
[field: SerializeField] [field: Min(0f)]
|
|
||||||
public float MinVelocityWhenThrown { get; private set; } = 5f;
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: f3b49b8d7dbc43dfbd074996aa811570
|
|
||||||
timeCreated: 1648908811
|
|
||||||
@ -76,7 +76,7 @@ public class MinionThrower : MonoBehaviour {
|
|||||||
|
|
||||||
var newMinion = Instantiate(minionBar.GetCurrentMinion().gameObject, transform.position + new Vector3(throwDirection.x, throwDirection.y, 0f) * 1f, Quaternion.identity)
|
var newMinion = Instantiate(minionBar.GetCurrentMinion().gameObject, transform.position + new Vector3(throwDirection.x, throwDirection.y, 0f) * 1f, Quaternion.identity)
|
||||||
.GetComponent<Monster>();
|
.GetComponent<Monster>();
|
||||||
if (movement.GetSafeZone() is {} safeZone) {
|
if (movement.GetSafeZoneIfImmobile() is {} safeZone) {
|
||||||
newMinion.thrownFromSafeZone = true;
|
newMinion.thrownFromSafeZone = true;
|
||||||
newMinion.thrownTargetPosition = safeZone.GetOutsidePosition(throwDirection);
|
newMinion.thrownTargetPosition = safeZone.GetOutsidePosition(throwDirection);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class Monster : AIEntity {
|
public class Monster : AIEntity {
|
||||||
public bool thrownFromSafeZone;
|
[HideInInspector] public bool thrownFromSafeZone;
|
||||||
public Vector3 thrownTargetPosition;
|
[HideInInspector] public Vector3 thrownTargetPosition;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
override protected void Start()
|
override protected void Start()
|
||||||
@ -65,17 +65,14 @@ public class Monster : AIEntity {
|
|||||||
public override void EnterState() {
|
public override void EnterState() {
|
||||||
base.EnterState();
|
base.EnterState();
|
||||||
|
|
||||||
entity.rb.SetEnabled(false);
|
entity.rb.velocity = entity.direction * entity.AIStats.throwForce;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void LeaveState() {
|
public override BaseState? FixedUpdateState() {
|
||||||
base.LeaveState();
|
Debug.Log($"Velocity: {entity.rb.velocity.magnitude}");
|
||||||
entity.rb.SetEnabled(true);
|
return entity.rb.velocity.magnitude < entity.AIStats.MinVelocityWhenThrown
|
||||||
}
|
|
||||||
|
|
||||||
public override BaseState? FixedUpdateState()
|
|
||||||
=> entity.rb.velocity.magnitude < entity.stats.MinVelocityWhenThrown
|
|
||||||
? new FindTargetState(entity)
|
? new FindTargetState(entity)
|
||||||
: null;
|
: null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,8 +49,8 @@ public class PlayerMovement : MonoBehaviour {
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public SafeZone? GetSafeZone() {
|
public SafeZone? GetSafeZoneIfImmobile() {
|
||||||
return safeZone;
|
return currentState is ImmobileMovementState ? safeZone : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Inputs
|
#region Inputs
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user