Added particle and bug fixes #437

Merged
glencelow merged 7 commits from PlayerController into main 2023-03-24 16:09:43 +08:00
4 changed files with 91 additions and 15 deletions
Showing only changes of commit 6ddc5c35cb - Show all commits

View File

@ -2899,7 +2899,7 @@
- EID: 2
Name: Player
IsActive: true
NumberOfChildren: 7
NumberOfChildren: 8
Components:
Transform Component:
Translate: {x: 2.35245037, y: 0.0613552481, z: 7.10571432}
@ -2963,6 +2963,8 @@
heavyMultiper: 0.5
silhouettePlayer: 462
silhouetteBag: 465
leftParticle: 573
rightParticle: 574
- Type: PickAndThrow
Enabled: true
throwForce: [10, 4, 10]
@ -3118,17 +3120,17 @@
IsActive: true
Scripts: ~
- EID: 573
Name: Smoke
Name: LeftSmoke
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -0.00712490082, y: 0.056717217, z: -0.0870996416}
Translate: {x: 0.0899999142, y: 0.100000001, z: -6.25735765e-08}
Rotate: {x: -5.83341553e-08, y: -3.14159274, z: 1.10461471e-08}
Scale: {x: 1.00000012, y: 1, z: 1.00000012}
IsActive: true
classSHADE::SHParticleEmitterComponent:
Emission Count: 2
Emission Count: 8
Is Passive: false
Emission Interval: 0
Min Life: 0.100000001
@ -3144,7 +3146,37 @@
Texture Asset ID: 56224060
Custom Update Shader Asset ID: 42141152
Color Tint: {x: 1, y: 1, z: 1, w: 1}
Acceleration: {x: 0, y: 0, z: 0}
Acceleration: {x: 0, y: 0.0500000007, z: 0}
IsActive: true
Scripts: ~
- EID: 574
Name: RightSmoke
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -0.0900000036, y: 0.100000001, z: -1.03427794e-07}
Rotate: {x: -5.83341553e-08, y: -3.14159274, z: 1.10461471e-08}
Scale: {x: 1.00000012, y: 1, z: 1.00000012}
IsActive: true
classSHADE::SHParticleEmitterComponent:
Emission Count: 8
Is Passive: false
Emission Interval: 0
Min Life: 0.100000001
Max Life: 2
Minimum Speed: 1
Maximum Speed: 1.5
Minimum Size: 0.100000001
Maximum Size: 0.100000001
Size Decay: 0.907000005
Angular Ranges And Offset: {x: 0.779999971, y: 0, z: -1.57070005, w: 0}
Rotation Speed: 0.805999994
Rotation Decay: 0
Texture Asset ID: 56224060
Custom Update Shader Asset ID: 42141152
Color Tint: {x: 1, y: 1, z: 1, w: 1}
Acceleration: {x: 0, y: 0.0500000007, z: 0}
IsActive: true
Scripts: ~
- EID: 239

View File

@ -6,6 +6,7 @@ public class PlayerRunState : BaseState
{
private float timer;
private float delay = 0.25f;
private bool left = true;
public PlayerRunState(StateMachine stateMachine) : base(stateMachine)
{
@ -15,6 +16,7 @@ public class PlayerRunState : BaseState
{
//Debug.Log("WALK ENTER");
AudioHandler.audioClipHandlers["footsteps"].Play();
timer = delay;
if (PlayerAnimations.Instance)
{
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerRunClip);
@ -30,8 +32,28 @@ public class PlayerRunState : BaseState
if (timer > delay)
{
if (left)
{
if (machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y > 0.0f)
machine.GetScript<PlayerController>().Leftsmoke.AngularOffsets = new Vector2(machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y - (MathF.PI * 1.5f), machine.GetScript<PlayerController>().Leftsmoke.AngularOffsets.y);
else
machine.GetScript<PlayerController>().Leftsmoke.AngularOffsets = new Vector2(machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y + (MathF.PI * 0.5f), machine.GetScript<PlayerController>().Leftsmoke.AngularOffsets.y);
machine.GetScript<PlayerController>().Leftsmoke.Emit();
left = false;
}
else
{
if (machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y > 0.0f)
machine.GetScript<PlayerController>().Rightsmoke.AngularOffsets = new Vector2(machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y - (MathF.PI * 1.5f), machine.GetScript<PlayerController>().Rightsmoke.AngularOffsets.y);
else
machine.GetScript<PlayerController>().Rightsmoke.AngularOffsets = new Vector2(machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y + (MathF.PI * 0.5f), machine.GetScript<PlayerController>().Rightsmoke.AngularOffsets.y);
machine.GetScript<PlayerController>().Rightsmoke.Emit();
left = true;
}
AudioHandler.audioClipHandlers["footsteps"].Play();
machine.GetScript<PlayerController>().smoke.Emit();
timer = 0;
}
}

View File

@ -6,6 +6,7 @@ public class PlayerWalkState : BaseState
{
private float timer;
private float delay = 0.4f;
private bool left = true;
public PlayerWalkState(StateMachine stateMachine) : base(stateMachine)
{
stateName = "Walk State";
@ -13,7 +14,6 @@ public class PlayerWalkState : BaseState
public override void OnEnter()
{
//Debug.Log("WALK ENTER");
AudioHandler.audioClipHandlers["footsteps"].Play();
timer = delay;
machine.GetScript<PlayerController>().playLandedAnimation = false;
@ -48,14 +48,28 @@ public class PlayerWalkState : BaseState
if (timer > delay)
{
if (left)
{
if (machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y > 0.0f)
machine.GetScript<PlayerController>().smoke.AngularOffsets = new Vector2(machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y - (MathF.PI * 1.5f), machine.GetScript<PlayerController>().smoke.AngularOffsets.y);
machine.GetScript<PlayerController>().Leftsmoke.AngularOffsets = new Vector2(machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y - (MathF.PI * 1.5f), machine.GetScript<PlayerController>().Leftsmoke.AngularOffsets.y);
else
machine.GetScript<PlayerController>().smoke.AngularOffsets = new Vector2(machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y + (MathF.PI * 0.5f), machine.GetScript<PlayerController>().smoke.AngularOffsets.y);
machine.GetScript<PlayerController>().Leftsmoke.AngularOffsets = new Vector2(machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y + (MathF.PI * 0.5f), machine.GetScript<PlayerController>().Leftsmoke.AngularOffsets.y);
machine.GetScript<PlayerController>().Leftsmoke.Emit();
left = false;
}
else
{
if (machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y > 0.0f)
machine.GetScript<PlayerController>().Rightsmoke.AngularOffsets = new Vector2(machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y - (MathF.PI * 1.5f), machine.GetScript<PlayerController>().Rightsmoke.AngularOffsets.y);
else
machine.GetScript<PlayerController>().Rightsmoke.AngularOffsets = new Vector2(machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y + (MathF.PI * 0.5f), machine.GetScript<PlayerController>().Rightsmoke.AngularOffsets.y);
machine.GetScript<PlayerController>().Rightsmoke.Emit();
left = true;
}
AudioHandler.audioClipHandlers["footsteps"].Play();
machine.GetScript<PlayerController>().smoke.Emit();
timer = 0;
}
}

View File

@ -24,7 +24,8 @@ public class PlayerController : Script
public CameraArm camArm { get; set; }
private PickAndThrow pat;
public StateMachine stateMachine { get; set; }
public ParticleEmitter smoke { get; set; }
public ParticleEmitter Leftsmoke { get; set; }
public ParticleEmitter Rightsmoke { get; set; }
public bool holdItem { get; set; }
public bool isAiming { get; set; }
@ -93,6 +94,10 @@ public class PlayerController : Script
public bool playLandedAnimation { get; set; }
public GameObject leftParticle;
public GameObject rightParticle;
protected override void awake()
{
//default setup
@ -147,9 +152,12 @@ public class PlayerController : Script
playLandedAnimation = false;
smoke = GetComponentInChildren<ParticleEmitter>();
if (!smoke)
Debug.LogError("ParticleEmitter MISSING");
Leftsmoke = leftParticle.GetComponent<ParticleEmitter>();
if (!Leftsmoke)
Debug.LogError("left ParticleEmitter MISSING");
Rightsmoke = rightParticle.GetComponent<ParticleEmitter>();
if (!Leftsmoke)
Debug.LogError("right ParticleEmitter MISSING");
}
protected override void start()