Skip to content

Commit 7ef23de

Browse files
committed
feat(action): expose custom variable to throw action
1 parent cbed8ff commit 7ef23de

File tree

1 file changed

+30
-24
lines changed

1 file changed

+30
-24
lines changed

Assets/JCSUnity/Scripts/Actions/3D/JCS_3DThrowAction.cs

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,9 @@ public class JCS_3DThrowAction : MonoBehaviour
2929
[SerializeField]
3030
private KeyCode mTestWithVelKey = KeyCode.None;
3131

32-
[Tooltip("Force to hit the target.")]
33-
[SerializeField]
34-
[Range(0.1f, 300.0f)]
35-
private float mForce = 20.0f;
36-
3732
[Tooltip("Key to use to test using the time function.")]
3833
[SerializeField]
3934
private KeyCode mTestWithTimeKey = KeyCode.None;
40-
41-
[Tooltip("Target time to hit the target.")]
42-
[SerializeField]
43-
[Range(1.0f, 10.0f)]
44-
private float mTime = 1.0f;
4535
#endif
4636

4737
[Separator("Check Variables (JCS_3DThrowAction)")]
@@ -62,6 +52,16 @@ public class JCS_3DThrowAction : MonoBehaviour
6252
[Range(0.1f, 30.0f)]
6353
private float mGravityProduct = 1.0f;
6454

55+
[Tooltip("Force to hit the target.")]
56+
[SerializeField]
57+
[Range(0.1f, 300.0f)]
58+
private float mForce = 20.0f;
59+
60+
[Tooltip("Target time to hit the target.")]
61+
[SerializeField]
62+
[Range(1.0f, 10.0f)]
63+
private float mTime = 1.0f;
64+
6565
[Tooltip("Type of the delta time.")]
6666
[SerializeField]
6767
private JCS_TimeType mTimeType = JCS_TimeType.DELTA_TIME;
@@ -75,6 +75,8 @@ public class JCS_3DThrowAction : MonoBehaviour
7575
public bool Active { get { return this.mActive; } set { this.mActive = value; } }
7676
public Vector3 Velocity { get { return this.mVelocity; } }
7777
public float GravityProduct { get { return this.mGravityProduct; } set { this.mGravityProduct = value; } }
78+
public float Force { get { return this.mForce; } set { this.mForce = value; } }
79+
public float Time { get { return this.mTime; } set { this.mTime = value; } }
7880
public JCS_TimeType DeltaTimeType { get { return this.mTimeType; } set { this.mTimeType = value; } }
7981
public bool FaceFoward { get { return this.mFaceFoward; } set { this.mFaceFoward = value; } }
8082

@@ -111,10 +113,10 @@ private void Update()
111113
private void Test()
112114
{
113115
if (Input.GetKeyDown(mTestWithVelKey))
114-
ThrowByForce(mTestTarget.position, mForce);
116+
ThrowByForce(mTestTarget.position);
115117

116118
if (Input.GetKeyDown(mTestWithTimeKey))
117-
ThrowByTime(mTestTarget.position, mTime);
119+
ThrowByTime(mTestTarget.position);
118120
}
119121
#endif
120122

@@ -124,17 +126,19 @@ private void Test()
124126
/// <param name="startPos"> Point to start this action. </param>
125127
/// <param name="targetPos"> Point you want to hit. </param>
126128
/// <param name="time"> Certain time will reach the target position. </param>
129+
public void ThrowByTime(Vector3 startPos, Vector3 targetPos)
130+
{
131+
ThrowByTime(startPos, targetPos, mTime);
132+
}
127133
public void ThrowByTime(Vector3 startPos, Vector3 targetPos, float time)
128134
{
129135
this.transform.position = startPos;
130136
ThrowByTime(targetPos, time);
131137
}
132-
133-
/// <summary>
134-
/// Do the throw action by time.
135-
/// </summary>
136-
/// <param name="targetPos"> Point you want to hit. </param>
137-
/// <param name="time"> Time. </param>
138+
public void ThrowByTime(Vector3 targetPos)
139+
{
140+
ThrowByTime(targetPos, mTime);
141+
}
138142
public void ThrowByTime(Vector3 targetPos, float time)
139143
{
140144
Vector3 displacement = targetPos - this.transform.position;
@@ -153,17 +157,19 @@ public void ThrowByTime(Vector3 targetPos, float time)
153157
/// <param name="startPos"> Point to start this action. </param>
154158
/// <param name="targetPos"> Point you want to hit. </param>
155159
/// <param name="vel"> velocity to hit the point. </param>
160+
public void ThrowByForce(Vector3 startPos, Vector3 targetPos)
161+
{
162+
ThrowByForce(startPos, targetPos, mForce);
163+
}
156164
public void ThrowByForce(Vector3 startPos, Vector3 targetPos, float vel)
157165
{
158166
this.transform.position = startPos;
159167
ThrowByForce(targetPos, vel);
160168
}
161-
162-
/// <summary>
163-
/// Do the throw action by calculate the kinematic.
164-
/// </summary>
165-
/// <param name="targetPos"> Point you want to hit. </param>
166-
/// <param name="vel"> velocity to hit the point. </param>
169+
public void ThrowByForce(Vector3 targetPos)
170+
{
171+
ThrowByForce(targetPos, mForce);
172+
}
167173
public void ThrowByForce(Vector3 targetPos, float vel)
168174
{
169175
float distance = Vector3.Distance(targetPos, this.transform.position);

0 commit comments

Comments
 (0)