Skip to content

Commit fcfb2e9

Browse files
committed
Update 3D player moduels.
1 parent e8fb348 commit fcfb2e9

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ public class JCS_3DGoStraightAction
2323
[Header("** Runtime Variables (JCS_3DGoStraightAction) **")]
2424

2525
[Tooltip("How fast it moves.")]
26-
[SerializeField] [Range(-500.0f, 500.0f)]
26+
[SerializeField]
27+
[Range(-500.0f, 500.0f)]
2728
private float mMoveSpeed = 10.0f;
2829

2930
[Tooltip("Which axis it moves.")]
3031
[SerializeField]
3132
private JCS_Axis mAxis = JCS_Axis.AXIS_X;
3233

33-
3434
[Header("- Randomize Settings (JCS_3DGoStraightAction)")]
3535

3636
[Tooltip(@"Randomize the speed depends on positive
@@ -39,18 +39,17 @@ [SerializeField] [Range(-500.0f, 500.0f)]
3939
private bool mRandomizeSpeedAtStart = false;
4040

4141
[Tooltip("Value randomize the move speed.")]
42-
[SerializeField] [Range(0.0f, 10.0f)]
42+
[SerializeField]
43+
[Range(0.0f, 10.0f)]
4344
private float mRandomSpeedValue = 5.0f;
4445

45-
4646
/* Setter & Getter */
4747

4848
public float MoveSpeed { get { return this.mMoveSpeed; } set { this.mMoveSpeed = value; } }
4949
public JCS_Axis Axis { get { return this.mAxis; } set { this.mAxis = value; } }
5050
public bool RandomizeSpeedAtStart { get { return this.mRandomizeSpeedAtStart; } set { this.mRandomizeSpeedAtStart = value; } }
5151
public float RandomSpeedValue { get { return this.mRandomSpeedValue; } set { this.mRandomSpeedValue = value; } }
5252

53-
5453
/* Functions */
5554

5655
private void Start()
@@ -66,7 +65,7 @@ private void Start()
6665
*
6766
* NOTE: if you want this to be accurate use FixedUpdate.
6867
*/
69-
/* Comment either one of them. */
68+
/* Comment either one of them. */
7069
//private void Update()
7170
private void FixedUpdate()
7271
{
@@ -93,7 +92,7 @@ private void FixedUpdate()
9392

9493
// if is valid, do action.
9594
//if (!JCS_Mathf.IsNaN(newPos))
96-
this.transform.Translate(newPos);
95+
this.transform.Translate(newPos);
9796
}
9897
}
9998
}

Assets/JCSUnity/Scripts/GameObject/3D/JCS_3DPlayer.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,32 @@ public class JCS_3DPlayer
2020
{
2121
/* Variables */
2222

23-
[SerializeField] private float mRotateSpeed = 25f;
23+
[Header("** Runtime Variables (JCS_3DPlayer) **")]
2424

25+
[Tooltip("How fast it rotates.")]
26+
[SerializeField]
27+
[Range(0.0f, 3000.0f)]
28+
protected float mRotateSpeed = 25.0f;
2529

2630
/* Setter & Getter */
2731

32+
public float RotateSpeed { get { return this.mRotateSpeed; } }
33+
2834
/* Functions */
2935

30-
protected override void FixedUpdate()
36+
protected override void Update()
3137
{
38+
base.Update();
39+
3240
PlayerInput();
41+
}
3342

43+
protected override void FixedUpdate()
44+
{
3445
if (!mCharacterController.isGrounded)
3546
mVelocity.y -= (JCS_GameConstant.GRAVITY * Time.deltaTime * JCS_GameSettings.instance.GRAVITY_PRODUCT);
3647

37-
mCharacterController.Move(mVelocity * Time.deltaTime);
48+
base.FixedUpdate();
3849
}
3950

4051
/// <summary>
@@ -61,7 +72,7 @@ public override void ControlEnable(bool act)
6172
/// <summary>
6273
/// Play input's design.
6374
/// </summary>
64-
public void PlayerInput()
75+
protected virtual void PlayerInput()
6576
{
6677
if (JCS_Input.GetKey(KeyCode.RightArrow))
6778
{
@@ -154,7 +165,7 @@ public override void Ghost()
154165

155166
private void RotateRelativeToCamera()
156167
{
157-
168+
// empty.
158169
}
159170
}
160171
}

Assets/JCSUnity/Scripts/Interfaces/JCS_Player.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public abstract class JCS_Player
2323
protected CharacterController mCharacterController = null;
2424
protected JCS_CharacterControllerInfo mCharacterControllerInfo = null;
2525

26-
2726
[Header("** Runtime Variables (JCS_Player) **")]
2827

2928
[Tooltip("How fast this player moves.")]
@@ -32,7 +31,8 @@ public abstract class JCS_Player
3231

3332
[Tooltip("Move speed of this player.")]
3433
[SerializeField]
35-
protected float mMoveSpeed = 0.0f;
34+
[Range(0.0f, 3000.0f)]
35+
protected float mMoveSpeed = 10.0f;
3636

3737
[Tooltip("Is the player controllable?")]
3838
[SerializeField]

0 commit comments

Comments
 (0)