diff --git a/SHADE_Engine/src/ECS_Base/Managers/SHSystemManager.cpp b/SHADE_Engine/src/ECS_Base/Managers/SHSystemManager.cpp
index 551233db..057568d6 100644
--- a/SHADE_Engine/src/ECS_Base/Managers/SHSystemManager.cpp
+++ b/SHADE_Engine/src/ECS_Base/Managers/SHSystemManager.cpp
@@ -29,7 +29,7 @@ namespace SHADE
{
system.second->Init();
#ifdef _DEBUG
- std::cout << system.first << " Init" << std::endl;
+ SHLOG_INFO("Initialising System {}...", system.first)
#endif
}
}
diff --git a/SHADE_Managed/src/Components/Transform.cxx b/SHADE_Managed/src/Components/Transform.cxx
index 98f0da4f..927ce87f 100644
--- a/SHADE_Managed/src/Components/Transform.cxx
+++ b/SHADE_Managed/src/Components/Transform.cxx
@@ -87,15 +87,6 @@ namespace SHADE
{
GetNativeComponent()->SetWorldScale(Convert::ToNative(val));
}
- Transform^ Transform::Parent::get()
- {
- auto node = SHSceneManager::GetCurrentSceneGraph().GetNode(owner.GetEntity());
- if (!node)
- throw gcnew System::InvalidOperationException("[Transform] Unable to retrieve SceneGraphNode for an Entity.");
-
- const auto PARENT = node->GetParent();
- return PARENT ? gcnew Transform(PARENT->GetEntityID()) : nullptr;
- }
/*---------------------------------------------------------------------------------*/
/* Constructors */
@@ -103,21 +94,4 @@ namespace SHADE
Transform::Transform(Entity entity)
: Component(entity)
{}
-
- /*---------------------------------------------------------------------------------*/
- /* Usage Functions */
- /*---------------------------------------------------------------------------------*/
-
- void Transform::SetParent(Transform^ parent, bool worldPositionStays)
- {
- auto& sceneGraph = SHSceneManager::GetCurrentSceneGraph();
- auto node = sceneGraph.GetNode(owner.GetEntity());
- if (!node)
- throw gcnew System::InvalidOperationException("[Transform] Unable to retrieve SceneGraphNode for an Entity.");
-
- if (parent)
- node->SetParent(sceneGraph.GetNode(parent->owner.GetEntity()));
- else
- sceneGraph.SetParent(parent->owner.GetEntity(), nullptr);
- }
}
diff --git a/SHADE_Managed/src/Components/Transform.hxx b/SHADE_Managed/src/Components/Transform.hxx
index bbe9fd19..942c6224 100644
--- a/SHADE_Managed/src/Components/Transform.hxx
+++ b/SHADE_Managed/src/Components/Transform.hxx
@@ -107,30 +107,6 @@ namespace SHADE
Vector3 get();
void set(Vector3 val);
}
- ///
- /// Parent Transform that affects this Transform.
- ///
- property Transform^ Parent
- {
- Transform^ get();
- }
-
- /*-----------------------------------------------------------------------------*/
- /* Usage Functions */
- /*-----------------------------------------------------------------------------*/
- ///
- /// Sets the parent of this Transform component.
- ///
- ///
- /// Entity that contains the Transform component that this Transform will be
- /// parented to. If null, unparenting will occur.
- ///
- ///
- /// If true, the transform values of this Transform component will retain their
- /// pre-parent-change global transforms. The local transform values will be
- /// modified to ensure that the global transforms do not change.
- ///
- void SetParent(Transform^ parent, bool worldPositionStays);
};
}
diff --git a/SHADE_Managed/src/Engine/GameObject.cxx b/SHADE_Managed/src/Engine/GameObject.cxx
index f4c16f4f..7ceabfed 100644
--- a/SHADE_Managed/src/Engine/GameObject.cxx
+++ b/SHADE_Managed/src/Engine/GameObject.cxx
@@ -17,6 +17,7 @@ of DigiPen Institute of Technology is prohibited.
#include "GameObject.hxx"
// External Dependencies
#include "ECS_Base/Managers/SHEntityManager.h"
+#include "Scene/SHSceneGraph.h"
// Project Headers
#include "ECS.hxx"
#include "Utility/Convert.hxx"
@@ -76,6 +77,27 @@ namespace SHADE
{
return entity;
}
+ GameObject^ GameObject::Parent::get()
+ {
+ const auto& SCENE_GRAPH = SHSceneManager::GetCurrentSceneGraph();
+ const auto* ROOT = SCENE_GRAPH.GetRoot();
+
+ const auto* NODE = SCENE_GRAPH.GetNode(entity);
+ if (NODE == nullptr)
+ throw gcnew System::InvalidOperationException("Unable to retrieve SceneGraphNode for Entity " + entity.ToString());
+
+ const auto* PARENT = NODE->GetParent();
+ return PARENT != ROOT ? gcnew GameObject(PARENT->GetEntityID()) : nullptr;
+ }
+ void GameObject::Parent::set(GameObject^ newParent)
+ {
+ const auto& SCENE_GRAPH = SHSceneManager::GetCurrentSceneGraph();
+
+ if (newParent == nullptr)
+ SCENE_GRAPH.SetParent(entity, nullptr);
+ else
+ SCENE_GRAPH.SetParent(entity, newParent->EntityId);
+ }
/*---------------------------------------------------------------------------------*/
/* GameObject Property Functions */
@@ -159,11 +181,13 @@ namespace SHADE
/* Constructors */
/*---------------------------------------------------------------------------------*/
GameObject::GameObject(const SHEntity& entity)
- : entity { entity.GetEID() }
+ : entity { entity.GetEID() }
+ , children{ gcnew System::Collections::ArrayList }
{}
GameObject::GameObject(Entity entity)
- : entity { entity }
+ : entity { entity }
+ , children{ gcnew System::Collections::ArrayList }
{}
/*---------------------------------------------------------------------------------*/
diff --git a/SHADE_Managed/src/Engine/GameObject.hxx b/SHADE_Managed/src/Engine/GameObject.hxx
index 8eaa67f3..99296a91 100644
--- a/SHADE_Managed/src/Engine/GameObject.hxx
+++ b/SHADE_Managed/src/Engine/GameObject.hxx
@@ -93,6 +93,14 @@ namespace SHADE
{
Entity get();
}
+ ///
+ /// The parent entity for this GameObject.
+ ///
+ property GameObject^ Parent
+ {
+ GameObject^ get();
+ void set(GameObject^);
+ }
/*-----------------------------------------------------------------------------*/
/* GameObject Property Functions */
@@ -112,6 +120,7 @@ namespace SHADE
/// Whether to activate or deactivate this GameObject.
///
void SetActive(bool active);
+
/*-----------------------------------------------------------------------------*/
/* Component Access Functions */
@@ -242,7 +251,8 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/
/* Data Members */
/*-----------------------------------------------------------------------------*/
- Entity entity;
+ Entity entity;
+ System::Collections::ArrayList^ children;
public:
/*-----------------------------------------------------------------------------*/
diff --git a/TempScriptsFolder/PickAndThrow.cs b/TempScriptsFolder/PickAndThrow.cs
new file mode 100644
index 00000000..834a508c
--- /dev/null
+++ b/TempScriptsFolder/PickAndThrow.cs
@@ -0,0 +1,30 @@
+using SHADE;
+using System;
+using static PlayerController;
+
+public class PickAndThrow : Script
+{
+ private PlayerController pc;
+ public uint itemEID;
+ Transform itemHoldLocation;
+ public PickAndThrow(GameObject gameObj) : base(gameObj) { }
+ protected override void awake()
+ {
+ pc = GetScript();
+ itemHoldLocation = GetComponentInChildren();
+ }
+ protected override void update()
+ {
+ if (pc != null && pc.holdItem)
+ {
+ }
+ }
+ protected override void onCollisionEnter(CollisionInfo info)
+ {
+ if (info.GameObject.Name == "item" && Input.GetKey(Input.KeyCode.E))
+ {
+ pc.holdItem = true;
+ itemEID = info.GameObject.EntityId;
+ }
+ }
+}
\ No newline at end of file
diff --git a/TempScriptsFolder/PlayerController.cs b/TempScriptsFolder/PlayerController.cs
index 98c3d3b5..36e19860 100644
--- a/TempScriptsFolder/PlayerController.cs
+++ b/TempScriptsFolder/PlayerController.cs
@@ -10,7 +10,7 @@ public class PlayerController : Script
IDILE,
WALKING,
RUNNING,
- INAIR,
+ JUMP,
FALLING,
HOLDING,
CAUGHT,
@@ -19,26 +19,48 @@ public class PlayerController : Script
private RigidBody rb;
private Transform tranform;
- private int xAxisMove;
- private int zAxisMove;
+
+ //to be remove
public float drag = 2.0f;
- private bool isMoveKeyPress = false;
+ public bool holdItem = false;
+ [SerializeField]
+ [Tooltip("The current state fo the raccoon")]
public RaccoonStates currentState = RaccoonStates.IDILE;
+ //Movement variables============================================================
+ [SerializeField]
+ [Tooltip("Max vel for walking")]
public float maxMoveVel = 2.0f;
+ [SerializeField]
+ [Tooltip("how much force is apply for walking")]
public float moveForce = 50.0f;
+ [SerializeField]
+ [Tooltip("increase the moveForce and maxMoveVel by its amt")]
public float sprintMultiplier = 2.0f;
+
private float oldForce;
private float maxOldVel;
private bool sprintIncreaseOnce = false;
+ private int xAxisMove;
+ private int zAxisMove;
+ private bool isMoveKeyPress = false;
+
+ [SerializeField]
+ [Tooltip("curr not working")]
public float rotationFactorPerFrame = 1.0f;
-
- public float initialJumpVel;
- public float maxJumpHeight = 1.0f;
- public float maxJumpTime = 0.5f;
- private bool isJumping = false;
- public bool isGrounded = true;
+ //Jumping vars==================================================================
+ [SerializeField]
+ [Tooltip("max height of the jump")]
+ public float maxJumpHeight = 4.0f;
+ [SerializeField]
+ [Tooltip("max amt of time it will take for the jump")]
+ public float maxJumpTime = 0.75f;
+ [SerializeField]
+ [Tooltip("increase gravity when falling")]
+ public float fallMultipler = 2.0f;
+ private float initialJumpVel;
+ private bool isGrounded = true;
private float gravity = -9.8f;
private float groundGravity = -0.5f;
@@ -80,7 +102,7 @@ public class PlayerController : Script
MoveKey();
- 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());
}
protected override void fixedUpdate()
@@ -111,10 +133,10 @@ public class PlayerController : Script
isMoveKeyPress = xAxisMove != 0 || zAxisMove != 0;
- if(isMoveKeyPress && currentState != RaccoonStates.RUNNING)
+ if(isMoveKeyPress && currentState != RaccoonStates.RUNNING && isGrounded)
currentState = RaccoonStates.WALKING;
- if (!isMoveKeyPress)
+ if (!isMoveKeyPress && isGrounded)
currentState = RaccoonStates.IDILE;
}
@@ -144,7 +166,7 @@ public class PlayerController : Script
private void Sprint()
{
- if (Input.GetKey(Input.KeyCode.LeftShift) && isMoveKeyPress)
+ if (Input.GetKey(Input.KeyCode.LeftShift) && isMoveKeyPress && isGrounded)
{
currentState = RaccoonStates.RUNNING;
if(!sprintIncreaseOnce)
@@ -158,7 +180,7 @@ public class PlayerController : Script
}
}
- if (Input.GetKeyUp(Input.KeyCode.LeftShift) && (currentState == RaccoonStates.RUNNING || currentState == RaccoonStates.IDILE))
+ if (Input.GetKeyUp(Input.KeyCode.LeftShift))
{
if(isMoveKeyPress)
currentState = RaccoonStates.WALKING;
@@ -173,23 +195,17 @@ public class PlayerController : Script
{
if (currentState == RaccoonStates.WALKING || currentState == RaccoonStates.RUNNING || currentState == RaccoonStates.IDILE)
{
- if (Input.GetKeyDown(Input.KeyCode.Space)&& isGrounded && rb != null)
+ if (Input.GetKeyDown(Input.KeyCode.Space) && isGrounded && rb != null)
{
- isJumping = true;
+ currentState = RaccoonStates.JUMP;
Vector3 v = rb.LinearVelocity;
- v.y = initialJumpVel;
+ v.y = initialJumpVel * 0.5f;
rb.LinearVelocity = v;
}
}
- if (rb != null)
- {
- if (rb.LinearVelocity.y > 0 && isJumping)
- currentState = RaccoonStates.INAIR;
- else if(rb.LinearVelocity.y < 0 && isJumping)
- currentState = RaccoonStates.FALLING;
-
- }
+ if(rb != null && !isGrounded && (rb.LinearVelocity.y < 0.0f || Input.GetKeyUp(Input.KeyCode.Space)))
+ currentState = RaccoonStates.FALLING;
}
private void Rotation()
@@ -215,7 +231,7 @@ public class PlayerController : Script
if (rb != null)
{
//check player vel.y if its close to zero its on the ground
- if (SHADE.Math.CompareFloat(rb.LinearVelocity.y, 0.0f, 0.1f))
+ if (SHADE.Math.CompareFloat(rb.LinearVelocity.y, 0.0f))
isGrounded = true;
else
isGrounded = false;
@@ -224,8 +240,20 @@ public class PlayerController : Script
if (isGrounded)
v.y = groundGravity;
- else
- v.y += gravity * (float)Time.DeltaTime;
+ else if (currentState == RaccoonStates.FALLING)
+ {
+ float prevYVel = v.y;
+ float newYVel = v.y + (gravity * fallMultipler * (float)Time.DeltaTime);
+ float nextYVel = (prevYVel + newYVel) * 0.5f;
+ v.y = nextYVel;
+ }
+ else
+ {
+ float prevYVel = v.y;
+ float newYVel = v.y + (gravity * (float)Time.DeltaTime);
+ float nextYVel = (prevYVel + newYVel) * 0.5f;
+ v.y = nextYVel;
+ }
rb.LinearVelocity = v;