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