Update changes to scripts and AudioSystem #224
|
@ -62,7 +62,7 @@
|
|||
NumberOfChildren: 3
|
||||
Components:
|
||||
Transform Component:
|
||||
Translate: {x: -3.06177855, y: -3.67369723, z: -5}
|
||||
Translate: {x: -0.867276311, y: -3.67369723, z: -9.76580334}
|
||||
Rotate: {x: -0, y: 0, z: 0}
|
||||
Scale: {x: 2, y: 2, z: 2}
|
||||
Renderable Component:
|
||||
|
@ -92,7 +92,7 @@
|
|||
Position Offset: {x: 0, y: 0.5, z: 0}
|
||||
Scripts:
|
||||
- Type: PlayerController
|
||||
currentState: 1
|
||||
currentState: 0
|
||||
maxMoveVel: 2
|
||||
moveForce: 50
|
||||
sprintMultiplier: 2
|
||||
|
@ -123,12 +123,12 @@
|
|||
Components:
|
||||
Transform Component:
|
||||
Translate: {x: 0, y: 0, z: 0}
|
||||
Rotate: {x: -0.109950222, y: 6.26573324, z: 0}
|
||||
Rotate: {x: -0.549778998, y: 1.59691703, z: 0}
|
||||
Scale: {x: 1, y: 1, z: 1}
|
||||
Camera Component:
|
||||
Position: {x: -3.06177855, y: -3.67369723, z: -5}
|
||||
Pitch: -6.29968357
|
||||
Yaw: 359.000061
|
||||
Position: {x: -0.867276311, y: -3.67369723, z: -9.76580334}
|
||||
Pitch: -31.5000153
|
||||
Yaw: 91.4966049
|
||||
Roll: 0
|
||||
Width: 1920
|
||||
Height: 1080
|
||||
|
|
|
@ -30,11 +30,10 @@ public class PlayerController : Script
|
|||
private Transform tranform;
|
||||
private Camera cam;
|
||||
private PickAndThrow pat;
|
||||
|
||||
private StateMachine stateMachine;
|
||||
|
||||
public bool holdItem { get; set; }
|
||||
[SerializeField]
|
||||
|
||||
[Tooltip("The current state fo the raccoon")]
|
||||
public RaccoonStates currentState = RaccoonStates.IDLE;
|
||||
|
||||
|
@ -114,12 +113,12 @@ public class PlayerController : Script
|
|||
if (pat == null)
|
||||
Debug.LogError("PickAndThrow is NULL!");
|
||||
|
||||
/* stateMachine = AddScript<StateMachine>();
|
||||
stateMachine = AddScript<StateMachine>();
|
||||
Dictionary<Type, BaseState> dictionary = new Dictionary<Type, BaseState>();
|
||||
dictionary.Add(typeof(IdleState), new IdleState(stateMachine));
|
||||
dictionary.Add(typeof(WalkState), new WalkState(stateMachine));
|
||||
dictionary.Add(typeof(RunState), new RunState(stateMachine));
|
||||
stateMachine.InitStateMachine(dictionary);*/
|
||||
stateMachine.InitStateMachine(dictionary);
|
||||
|
||||
}
|
||||
|
||||
|
@ -129,6 +128,8 @@ public class PlayerController : Script
|
|||
cam = GetComponentInChildren<Camera>();
|
||||
|
||||
GotCaught();
|
||||
//Debug.Log($"{currentState}");
|
||||
//Debug.Log($" axisX: {axisMove.x} axisY:{axisMove.y}");
|
||||
//Debug.Log($"X: {rb.LinearVelocity.x}" + $" Y: {rb.LinearVelocity.z}");
|
||||
//Debug.Log(currentState.ToString() + " x:" + rb.LinearVelocity.x.ToString() + " y:" + rb.LinearVelocity.y.ToString() + " z:" + rb.LinearVelocity.z.ToString());
|
||||
}
|
||||
|
@ -136,11 +137,21 @@ public class PlayerController : Script
|
|||
protected override void fixedUpdate()
|
||||
{
|
||||
//Rotation();
|
||||
if (rb)
|
||||
Debug.Log($"Before x: {rb.LinearVelocity.x} z:{rb.LinearVelocity.z}");
|
||||
|
||||
MoveKey();
|
||||
|
||||
if (rb)
|
||||
rb.AddForce(new Vector3(-rb.GetForce().x, -rb.GetForce().y, -rb.GetForce().z));
|
||||
|
||||
Move();
|
||||
Sprint();
|
||||
Jump();
|
||||
Gravity();
|
||||
|
||||
if (rb)
|
||||
Debug.Log($"After x: {rb.LinearVelocity.x} z:{rb.LinearVelocity.z}");
|
||||
}
|
||||
|
||||
|
||||
|
@ -174,6 +185,7 @@ public class PlayerController : Script
|
|||
|
||||
axisMove += new Vector2(camerAixs.x, camerAixs.z);
|
||||
}
|
||||
|
||||
if (Input.GetKey(Input.KeyCode.S))
|
||||
{
|
||||
Vector3 camerAixs = cam.GetForward();
|
||||
|
@ -183,6 +195,7 @@ public class PlayerController : Script
|
|||
zAxisMove = -camerAixs.z;
|
||||
axisMove -= new Vector2(camerAixs.x, camerAixs.z);
|
||||
}
|
||||
|
||||
if (Input.GetKey(Input.KeyCode.A))
|
||||
{
|
||||
Vector3 camerAixs = cam.GetRight();
|
||||
|
@ -192,6 +205,7 @@ public class PlayerController : Script
|
|||
zAxisMove = -camerAixs.z;
|
||||
axisMove -= new Vector2(camerAixs.x, camerAixs.z);
|
||||
}
|
||||
|
||||
if (Input.GetKey(Input.KeyCode.D))
|
||||
{
|
||||
Vector3 camerAixs = cam.GetRight();
|
||||
|
@ -201,6 +215,7 @@ public class PlayerController : Script
|
|||
zAxisMove = camerAixs.z;
|
||||
axisMove += new Vector2(camerAixs.x, camerAixs.z);
|
||||
}
|
||||
|
||||
axisMove.Normalise();
|
||||
isMoveKeyPress = xAxisMove != 0 || zAxisMove != 0;
|
||||
|
||||
|
@ -226,8 +241,7 @@ public class PlayerController : Script
|
|||
if (rb != null)
|
||||
{
|
||||
rb.AddForce(new Vector3(axisMove.x, 0.0f,axisMove.y) * moveForce);
|
||||
Debug.Log($"axis:{axisMove.x} moveforce: {moveForce} X: {rb.LinearVelocity.x}" + $" Z: {rb.LinearVelocity.z}");
|
||||
|
||||
|
||||
if (isMoveKeyPress)
|
||||
{
|
||||
if (rb.LinearVelocity.x > maxMoveVel || rb.LinearVelocity.x < -maxMoveVel)
|
||||
|
@ -253,6 +267,7 @@ public class PlayerController : Script
|
|||
currentState = RaccoonStates.RUNNING;
|
||||
if (stateMachine && !stateMachine.IsState(typeof(RunState)))
|
||||
stateMachine.SetState(typeof(RunState));
|
||||
|
||||
holdItem = false;
|
||||
if (!sprintIncreaseOnce)
|
||||
{
|
||||
|
@ -303,8 +318,9 @@ public class PlayerController : Script
|
|||
}
|
||||
}
|
||||
|
||||
if(rb != null && !isGrounded && (rb.LinearVelocity.y < 0.0f || Input.GetKeyUp(Input.KeyCode.Space)))
|
||||
if(!isGrounded && rb != null && (rb.LinearVelocity.y < 0.0f || Input.GetKeyUp(Input.KeyCode.Space)))
|
||||
currentState = RaccoonStates.FALLING;
|
||||
|
||||
}
|
||||
|
||||
private void Rotation()
|
||||
|
@ -331,7 +347,11 @@ public class PlayerController : Script
|
|||
{
|
||||
//check player vel.y if its close to zero its on the ground
|
||||
if (SHADE.Math.CompareFloat(rb.LinearVelocity.y, 0.0f))
|
||||
{
|
||||
isGrounded = true;
|
||||
if (currentState == RaccoonStates.FALLING)
|
||||
currentState = RaccoonStates.LANDED;
|
||||
}
|
||||
else
|
||||
isGrounded = false;
|
||||
|
||||
|
@ -384,23 +404,23 @@ public class WalkState : BaseState
|
|||
}
|
||||
public override void OnEnter()
|
||||
{
|
||||
Debug.Log("WALK ENTER");
|
||||
//Debug.Log("WALK ENTER");
|
||||
}
|
||||
public override void update()
|
||||
{
|
||||
Debug.Log("WALKING");
|
||||
//Debug.Log("WALKING");
|
||||
}
|
||||
public override void fixedUpdate()
|
||||
{
|
||||
Debug.Log("FIXED WALKING");
|
||||
//Debug.Log("FIXED WALKING");
|
||||
}
|
||||
public override void OnExit()
|
||||
{
|
||||
Debug.Log("WALK EXIT");
|
||||
//Debug.Log("WALK EXIT");
|
||||
}
|
||||
public override void onTriggerEnter(CollisionInfo info)
|
||||
{
|
||||
Debug.Log("TRIGGER");
|
||||
//Debug.Log("TRIGGER");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -413,19 +433,19 @@ public class RunState : BaseState
|
|||
}
|
||||
public override void OnEnter()
|
||||
{
|
||||
Debug.Log("Run ENTER");
|
||||
//Debug.Log("Run ENTER");
|
||||
}
|
||||
public override void update()
|
||||
{
|
||||
Debug.Log("RUNING");
|
||||
//Debug.Log("RUNING");
|
||||
}
|
||||
public override void fixedUpdate()
|
||||
{
|
||||
Debug.Log("FIXED RUNNING");
|
||||
//Debug.Log("FIXED RUNNING");
|
||||
}
|
||||
public override void OnExit()
|
||||
{
|
||||
Debug.Log("Run EXIT");
|
||||
//Debug.Log("Run EXIT");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -437,19 +457,19 @@ public class IdleState : BaseState
|
|||
}
|
||||
public override void OnEnter()
|
||||
{
|
||||
Debug.Log("IDLE ENTER");
|
||||
//Debug.Log("IDLE ENTER");
|
||||
}
|
||||
public override void update()
|
||||
{
|
||||
Debug.Log("IDLING");
|
||||
//Debug.Log("IDLING");
|
||||
}
|
||||
public override void fixedUpdate()
|
||||
{
|
||||
Debug.Log("FIXED IDLING");
|
||||
//Debug.Log("FIXED IDLING");
|
||||
}
|
||||
public override void OnExit()
|
||||
{
|
||||
Debug.Log("IDLE EXIT");
|
||||
//Debug.Log("IDLE EXIT");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,6 @@ public class StateMachine : Script
|
|||
|
||||
protected override void update()
|
||||
{
|
||||
Debug.Log("updating");
|
||||
if (currentState != (null))
|
||||
{
|
||||
currentStateName = currentState.GetStateName();
|
||||
|
@ -78,7 +77,6 @@ public class StateMachine : Script
|
|||
|
||||
protected override void fixedUpdate()
|
||||
{
|
||||
Debug.Log("fix update");
|
||||
if (currentState != (null))
|
||||
{
|
||||
currentStateName = currentState.GetStateName();
|
||||
|
|
Loading…
Reference in New Issue