more quaternion math mistakes
This commit is contained in:
parent
544868c386
commit
b598d87f52
@ -18,6 +18,8 @@ public class PlayerController : MonoBehaviour
|
|||||||
bool canMove = true;
|
bool canMove = true;
|
||||||
Rigidbody rb;
|
Rigidbody rb;
|
||||||
|
|
||||||
|
private GameObject collisionGameObject = null;
|
||||||
|
|
||||||
float moveDirectionY;
|
float moveDirectionY;
|
||||||
|
|
||||||
public Vector3 jump;
|
public Vector3 jump;
|
||||||
@ -51,22 +53,31 @@ public class PlayerController : MonoBehaviour
|
|||||||
Debug.Log("Jump");
|
Debug.Log("Jump");
|
||||||
rb.AddForce(transform.up * jumpSpeed * 500 * Time.deltaTime, ForceMode.Impulse);
|
rb.AddForce(transform.up * jumpSpeed * 500 * Time.deltaTime, ForceMode.Impulse);
|
||||||
}
|
}
|
||||||
|
if(this.collisionGameObject != null){
|
||||||
|
transform.rotation = Quaternion.Slerp(transform.rotation, this.collisionGameObject.transform.rotation, Time.deltaTime * 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
rb.MovePosition(rb.position + moveDirection);
|
rb.MovePosition(rb.position + moveDirection);
|
||||||
|
|
||||||
//characterController.Move(moveDirection * Time.deltaTime);
|
//characterController.Move(moveDirection * Time.deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnCollisionExit(Collision other) {
|
||||||
void OnCollisionEnter(Collision collision)
|
if (other.gameObject.tag == "platform")
|
||||||
{
|
{
|
||||||
if (collision.gameObject.tag == "platform")
|
this.collisionGameObject = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void OnCollisionEnter(Collision other)
|
||||||
{
|
{
|
||||||
-- FIXME:
|
if (other.gameObject.tag == "platform")
|
||||||
|
{
|
||||||
|
// FIXME:
|
||||||
var thisTransform = this.gameObject.transform;
|
var thisTransform = this.gameObject.transform;
|
||||||
thisTransform.eulerAngles = new Vector3(thisTransform.eulerAngles.x, thisTransform.eulerAngles.y, collision.transform.eulerAngles.z);
|
// thisTransform.eulerAngles = new Vector3(thisTransform.eulerAngles.x, thisTransform.eulerAngles.y, collision.transform.eulerAngles.z);
|
||||||
|
// thisTransform.rotation = new Quaternion(thisTransform.rotation.x, thisTransform.rotation.y, thisTransform.rotation.z, 1.0f) * Vector3.forward;
|
||||||
Vector3 gDirection = new Quaternion(0.0f, 0.0f, collision.gameObject.transform.rotation.z, 1.0f) * Vector3.down;
|
this.collisionGameObject = other.gameObject;
|
||||||
|
Vector3 gDirection = new Quaternion(0.0f, 0.0f, other.gameObject.transform.rotation.z, 1.0f) * Vector3.down;
|
||||||
|
|
||||||
Physics.gravity = gDirection * 9.81f;
|
Physics.gravity = gDirection * 9.81f;
|
||||||
Debug.Log(Physics.gravity);
|
Debug.Log(Physics.gravity);
|
||||||
|
Loading…
Reference in New Issue
Block a user