- Added chicken sounds to the chickens.
- Began work on a game room so the world can be more of a hangout area.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -18,11 +18,17 @@ public enum ChickenState
|
||||
|
||||
public class Chimken : UdonSharpBehaviour
|
||||
{
|
||||
[SerializeField] private Transform GroundRayStart;
|
||||
[SerializeField] private Transform GroundRayEnd;
|
||||
[SerializeField] private Transform WallRayStart;
|
||||
[SerializeField] private Transform WallRayEnd;
|
||||
[SerializeField] private AudioSource _AudioSource;
|
||||
[SerializeField] private TimerSounds _IdleSoundsTimer;
|
||||
[SerializeField] private TimerSounds _HeldSoundsTimer;
|
||||
[SerializeField] private TimerSounds _AirborneSoundsTimer;
|
||||
[Space]
|
||||
[SerializeField] private string _FollowUser = "";
|
||||
[Space]
|
||||
[SerializeField] private Transform _GroundRayStart;
|
||||
[SerializeField] private Transform _GroundRayEnd;
|
||||
[SerializeField] private Transform _WallRayStart;
|
||||
[SerializeField] private Transform _WallRayEnd;
|
||||
|
||||
[UdonSynced, FieldChangeCallback(nameof(AnimationState))] private ChickenState _AnimationState = 0;
|
||||
[UdonSynced] private bool _IsBeingHeld = false;
|
||||
@@ -58,7 +64,7 @@ public class Chimken : UdonSharpBehaviour
|
||||
{
|
||||
SetAnimationState(ChickenState.Held);
|
||||
}
|
||||
else if (Physics.Raycast(GroundRayStart.position, GroundRayStart.forward, out HitInfo, GroundRayEnd.localPosition.z))
|
||||
else if (Physics.Raycast(_GroundRayStart.position, _GroundRayStart.forward, out HitInfo, _GroundRayEnd.localPosition.z))
|
||||
{
|
||||
transform.position = HitInfo.point;
|
||||
Airborne = false;
|
||||
@@ -72,10 +78,10 @@ public class Chimken : UdonSharpBehaviour
|
||||
_WallColliderTimer -= Time.fixedDeltaTime;
|
||||
if (_WallColliderTimer <= 0.0f && _Moving)
|
||||
{
|
||||
if (Physics.Raycast(WallRayStart.position, WallRayStart.forward, out HitInfo, WallRayEnd.localPosition.z))
|
||||
if (Physics.Raycast(_WallRayStart.position, _WallRayStart.forward, out HitInfo, _WallRayEnd.localPosition.z))
|
||||
{
|
||||
float OldMovementDirection = _MovementDirectionDegrees;
|
||||
Vector3 ReflectedAngle = Vector3.Reflect(WallRayStart.forward, HitInfo.normal);
|
||||
Vector3 ReflectedAngle = Vector3.Reflect(_WallRayStart.forward, HitInfo.normal);
|
||||
_MovementDirectionDegrees = Vector3.SignedAngle(Vector3.forward, ReflectedAngle, Vector3.up);
|
||||
}
|
||||
_WallColliderTimer = 0.25f;
|
||||
@@ -127,22 +133,22 @@ public class Chimken : UdonSharpBehaviour
|
||||
transform.position += (transform.forward * Time.fixedDeltaTime * RUN_SPEED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_Moving && _PlayerToFollow == null)
|
||||
{
|
||||
transform.rotation = Quaternion.Euler(
|
||||
transform.eulerAngles.x,
|
||||
Mathf.LerpAngle(transform.rotation.eulerAngles.y, _MovementDirectionDegrees, TURN_LERP_SPEED),
|
||||
transform.eulerAngles.z);
|
||||
}
|
||||
else
|
||||
{
|
||||
float Angle = Vector3.SignedAngle(transform.forward, (PlayerPositionLateral - ChickenPositionLateral).normalized, transform.up);
|
||||
transform.rotation = Quaternion.Euler(
|
||||
transform.eulerAngles.x,
|
||||
Mathf.LerpAngle(transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.y + Angle, TURN_LERP_SPEED),
|
||||
transform.eulerAngles.z);
|
||||
if (_PlayerToFollow == null)
|
||||
{
|
||||
transform.rotation = Quaternion.Euler(
|
||||
transform.eulerAngles.x,
|
||||
Mathf.LerpAngle(transform.rotation.eulerAngles.y, _MovementDirectionDegrees, TURN_LERP_SPEED),
|
||||
transform.eulerAngles.z);
|
||||
}
|
||||
else
|
||||
{
|
||||
float Angle = Vector3.SignedAngle(transform.forward, (PlayerPositionLateral - ChickenPositionLateral).normalized, transform.up);
|
||||
transform.rotation = Quaternion.Euler(
|
||||
transform.eulerAngles.x,
|
||||
Mathf.LerpAngle(transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.y + Angle, TURN_LERP_SPEED),
|
||||
transform.eulerAngles.z);
|
||||
}
|
||||
}
|
||||
|
||||
// Reset roll and pitch to zero on every physics update so the chicken stays upright
|
||||
@@ -191,7 +197,7 @@ public class Chimken : UdonSharpBehaviour
|
||||
|
||||
private void SetAnimationState(ChickenState State)
|
||||
{
|
||||
if (Networking.IsOwner(gameObject))
|
||||
if (Networking.IsOwner(gameObject) && AnimationState != State)
|
||||
{
|
||||
AnimationState = State;
|
||||
_MovementDirectionDegrees = Random.Range(0.0f, 360.0f - float.MinValue);
|
||||
@@ -209,24 +215,30 @@ public class Chimken : UdonSharpBehaviour
|
||||
{
|
||||
case ChickenState.Idle:
|
||||
_MovementTimer = 4.0f;
|
||||
PlayIdleSounds();
|
||||
break;
|
||||
case ChickenState.Walk:
|
||||
_MovementTimer = 4.5f;
|
||||
_Moving = true;
|
||||
PlayIdleSounds();
|
||||
break;
|
||||
case ChickenState.Run:
|
||||
_MovementTimer = 1.2f;
|
||||
_Moving = true;
|
||||
PlayIdleSounds();
|
||||
break;
|
||||
case ChickenState.Eat:
|
||||
_MovementTimer = 6.0f;
|
||||
PlayIdleSounds();
|
||||
break;
|
||||
case ChickenState.Held:
|
||||
_MovementTimer = 0.0f;
|
||||
PlayHeldSounds();
|
||||
break;
|
||||
case ChickenState.Airborne:
|
||||
_MovementTimer = 0.0f;
|
||||
_Moving = true;
|
||||
PlayAirborneSounds();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -246,6 +258,28 @@ public class Chimken : UdonSharpBehaviour
|
||||
}
|
||||
|
||||
|
||||
private void PlayIdleSounds()
|
||||
{
|
||||
_HeldSoundsTimer.StopTimer();
|
||||
_AirborneSoundsTimer.StopTimer();
|
||||
_IdleSoundsTimer.StartTimer();
|
||||
}
|
||||
|
||||
private void PlayHeldSounds()
|
||||
{
|
||||
_IdleSoundsTimer.StopTimer();
|
||||
_AirborneSoundsTimer.StopTimer();
|
||||
_HeldSoundsTimer.StartTimer();
|
||||
}
|
||||
|
||||
private void PlayAirborneSounds()
|
||||
{
|
||||
_IdleSoundsTimer.StopTimer();
|
||||
_HeldSoundsTimer.StopTimer();
|
||||
_AirborneSoundsTimer.StartTimer();
|
||||
}
|
||||
|
||||
|
||||
private ChickenState AnimationState
|
||||
{
|
||||
set
|
||||
|
||||
Reference in New Issue
Block a user