Player move repair and add bgrotation script
This commit is contained in:
parent
02e26dd95a
commit
4bf7d9fc1a
@ -1628,8 +1628,8 @@ MonoBehaviour:
|
|||||||
isFalling: 0
|
isFalling: 0
|
||||||
jumpSpeed: 3
|
jumpSpeed: 3
|
||||||
inAir: 0
|
inAir: 0
|
||||||
lookSpeed: 7.5
|
lookSpeed: 5
|
||||||
lookXLimit: 8.75
|
lookXLimit: 10
|
||||||
playerCamera: {fileID: 3244356567913423211}
|
playerCamera: {fileID: 3244356567913423211}
|
||||||
rotationX: 0
|
rotationX: 0
|
||||||
runningParticles: {fileID: 1608137079}
|
runningParticles: {fileID: 1608137079}
|
||||||
|
19
Assets/Scripts/BGRotation.cs
Normal file
19
Assets/Scripts/BGRotation.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class BGRotation : MonoBehaviour
|
||||||
|
{
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
transform.Rotate(new Vector3(Random.Range(0,360), Random.Range(0, 360), Random.Range(0, 360)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTriggerEnter(Collider other)
|
||||||
|
{
|
||||||
|
if (other.tag == "platform")
|
||||||
|
{
|
||||||
|
Destroy(this.gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Scripts/BGRotation.cs.meta
Normal file
11
Assets/Scripts/BGRotation.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 057be10618539f04aa0b770181500753
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -39,6 +39,7 @@ public class PlayerController : MonoBehaviour
|
|||||||
private Vector3 saveDirection;
|
private Vector3 saveDirection;
|
||||||
private Vector3 downDirection;
|
private Vector3 downDirection;
|
||||||
private Vector3 platformForward;
|
private Vector3 platformForward;
|
||||||
|
private Vector3 platformRight;
|
||||||
|
|
||||||
private Vector3 follow = Vector3.zero;
|
private Vector3 follow = Vector3.zero;
|
||||||
|
|
||||||
@ -49,6 +50,7 @@ public class PlayerController : MonoBehaviour
|
|||||||
{
|
{
|
||||||
rb = GetComponent<Rigidbody>();
|
rb = GetComponent<Rigidbody>();
|
||||||
platformForward = Vector3.forward;
|
platformForward = Vector3.forward;
|
||||||
|
platformRight = Vector3.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disableCursor()
|
public void disableCursor()
|
||||||
@ -87,7 +89,7 @@ public class PlayerController : MonoBehaviour
|
|||||||
float curSpeedX = canMove ? (currentSpeed + speedModifier) : 0;
|
float curSpeedX = canMove ? (currentSpeed + speedModifier) : 0;
|
||||||
float curSpeedY = canMove ? (currentSpeed + currentSpeed + speedModifier) * Input.GetAxis("Horizontal") : 0;
|
float curSpeedY = canMove ? (currentSpeed + currentSpeed + speedModifier) * Input.GetAxis("Horizontal") : 0;
|
||||||
|
|
||||||
moveDirection = (platformForward * curSpeedX * Time.deltaTime) + (transform.right * curSpeedY * Time.deltaTime);
|
moveDirection = (transform.forward * curSpeedX * Time.deltaTime) + (transform.right * curSpeedY * Time.deltaTime);
|
||||||
|
|
||||||
if ((currentSpeed + speedModifier) >= maxSpeed && !runningParticles.isPlaying)
|
if ((currentSpeed + speedModifier) >= maxSpeed && !runningParticles.isPlaying)
|
||||||
{
|
{
|
||||||
@ -227,7 +229,7 @@ public class PlayerController : MonoBehaviour
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.downDirection = -other.GetContact(0).normal;
|
this.downDirection = -transform.up;
|
||||||
saveDirection = -other.GetContact(0).normal;
|
saveDirection = -other.GetContact(0).normal;
|
||||||
|
|
||||||
// TODO: Handle other PlatformTypes
|
// TODO: Handle other PlatformTypes
|
||||||
@ -291,6 +293,7 @@ public class PlayerController : MonoBehaviour
|
|||||||
gDirection = -other.GetContact(0).normal;
|
gDirection = -other.GetContact(0).normal;
|
||||||
}
|
}
|
||||||
platformForward = other.transform.forward;
|
platformForward = other.transform.forward;
|
||||||
|
platformRight = other.transform.right;
|
||||||
this.downDirection = gDirection;
|
this.downDirection = gDirection;
|
||||||
Physics.gravity = gDirection * 9.81f;
|
Physics.gravity = gDirection * 9.81f;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user