gamemode spawning
This commit is contained in:
@@ -36,6 +36,9 @@ namespace Game
|
||||
|
||||
public class PlayerActor : RigidBody
|
||||
{
|
||||
private PlayerMovement playerMovement;
|
||||
private RigidBody playerRigidBody;
|
||||
|
||||
public PlayerActor()
|
||||
{
|
||||
// Default internal values for RigidBody
|
||||
@@ -45,5 +48,29 @@ namespace Game
|
||||
AngularDamping = 0f;
|
||||
Constraints = RigidbodyConstraints.LockRotation;
|
||||
}
|
||||
|
||||
public override void OnBeginPlay()
|
||||
{
|
||||
base.OnBeginPlay();
|
||||
|
||||
playerMovement = FindScript<PlayerMovement>();
|
||||
playerRigidBody = FindActor<RigidBody>();
|
||||
}
|
||||
|
||||
public void SetPosition(Vector3 newPosition)
|
||||
{
|
||||
Position = newPosition;
|
||||
}
|
||||
|
||||
public void SetRotation(Vector3 eulerAngles)
|
||||
{
|
||||
playerMovement.ResetRotation(eulerAngles);
|
||||
}
|
||||
|
||||
public void Teleport(Vector3 newPosition, Vector3 eulerAngles)
|
||||
{
|
||||
SetPosition(newPosition);
|
||||
SetRotation(eulerAngles);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,6 +96,7 @@ namespace Game
|
||||
|
||||
[ReadOnly] public bool onGround;
|
||||
private RigidBody rigidBody;
|
||||
private Actor cameraHolder;
|
||||
|
||||
private Actor rootActor;
|
||||
private float startupTime;
|
||||
@@ -155,9 +156,9 @@ namespace Game
|
||||
Engine.RequestExit();
|
||||
};
|
||||
|
||||
rootActor = Actor.GetChild(0);
|
||||
|
||||
rootActor = Actor.GetChild("RootActor");
|
||||
rigidBody = Actor.As<RigidBody>();
|
||||
cameraHolder = rootActor.GetChild("CameraHolder");
|
||||
|
||||
//rigidBody.CollisionEnter += OnCollisionEnter;
|
||||
//rigidBody.TriggerEnter += OnTriggerEnter;
|
||||
@@ -205,13 +206,19 @@ namespace Game
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
Vector3 initialEulerAngles = Actor.Orientation.EulerAngles;
|
||||
viewPitch = initialEulerAngles.X;
|
||||
viewYaw = initialEulerAngles.Y;
|
||||
viewRoll = initialEulerAngles.Z;
|
||||
ResetRotation(Actor.Orientation.EulerAngles);
|
||||
}
|
||||
|
||||
public void ResetRotation(Vector3 eulerAngles)
|
||||
{
|
||||
viewPitch = eulerAngles.X;
|
||||
viewYaw = eulerAngles.Y;
|
||||
viewRoll = eulerAngles.Z;
|
||||
viewPitchLastFrame = viewPitch;
|
||||
viewYawLastFrame = viewYaw;
|
||||
viewRollLastFrame = viewRoll;
|
||||
|
||||
SetCameraEulerAngles(new Vector3(viewYaw, viewPitch, viewRoll));
|
||||
}
|
||||
|
||||
public override void OnUpdate()
|
||||
@@ -348,9 +355,6 @@ namespace Game
|
||||
|
||||
private void SetCameraEulerAngles(Vector3 viewAngles)
|
||||
{
|
||||
//Camera camera = rootActor.GetChild<Camera>();
|
||||
Actor cameraHolder = rootActor.GetChild("CameraHolder");
|
||||
|
||||
// Root orientation must be set first
|
||||
rootActor.Orientation = Quaternion.Euler(0, viewAngles.X, 0);
|
||||
cameraHolder.Orientation = Quaternion.Euler(viewAngles.Y, viewAngles.X, viewAngles.Z);
|
||||
|
||||
Reference in New Issue
Block a user