reverted last change partly (cam), added animation
This commit is contained in:
@@ -22,14 +22,8 @@ namespace Assets.Scripts.Player
|
||||
bool finishedGame = false;
|
||||
PlayerObject player;
|
||||
public float speed = 5f;
|
||||
DateTime jumpTimer;
|
||||
DateTime now;
|
||||
int bobbingDirection = -1;
|
||||
public float mouseSpeed = 100; //the sensibility
|
||||
public float controllerSpeed = 0.01f; //the sensibility
|
||||
float xMaxLimit = 45.0f;
|
||||
float xMinLimit = -45.0f;
|
||||
Vector2 rotation = Vector2.zero;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
@@ -144,24 +138,19 @@ namespace Assets.Scripts.Player
|
||||
|
||||
if (input.y != 0)
|
||||
{
|
||||
if (jumpTimer != null)
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(transform.position, -transform.up, out hit, Mathf.Infinity))
|
||||
{
|
||||
if (jumpTimer.AddSeconds(1).CompareTo(DateTime.Now) <= 0)
|
||||
if (hit.distance <= 1.5f)
|
||||
{
|
||||
jumpTimer = DateTime.Now;
|
||||
gameObject.GetComponent<Rigidbody>().velocity = new Vector3(0, 5, 0);
|
||||
audioHandler.playJump();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
jumpTimer = DateTime.Now;
|
||||
gameObject.GetComponent<Rigidbody>().velocity = new Vector3(0, 5, 0);
|
||||
audioHandler.playJump();
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 movement = new Vector3(input.x, 0, input.z);
|
||||
movement = camera.transform.TransformDirection(movement);
|
||||
movement.y = 0;
|
||||
gameObject.transform.Translate(movement * speed * Time.deltaTime);
|
||||
|
||||
if (input.z != 0)
|
||||
@@ -183,7 +172,7 @@ namespace Assets.Scripts.Player
|
||||
public void getRotation()
|
||||
{
|
||||
GameObject needle = GameObject.Find("imgNeedle");
|
||||
float rotation = gameObject.transform.rotation.eulerAngles.y;
|
||||
float rotation = GameObject.Find("Main Camera").transform.rotation.eulerAngles.y;
|
||||
if (rotation < 0)
|
||||
{
|
||||
rotation += 360;
|
||||
@@ -382,21 +371,5 @@ namespace Assets.Scripts.Player
|
||||
{
|
||||
player.regainSecondary(inventory.getEquipmentBonus()["MPR"], inventory.getEquipmentBonus()["MP"]);
|
||||
}
|
||||
|
||||
public void lookAround(Vector2 view, bool isController)
|
||||
{
|
||||
rotation.y += view.x;
|
||||
rotation.x += -view.y;
|
||||
rotation.x = Mathf.Clamp(rotation.x, xMinLimit, xMaxLimit);
|
||||
if (isController)
|
||||
{
|
||||
transform.eulerAngles = rotation * (controllerSpeed * Time.deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.eulerAngles = rotation * mouseSpeed;
|
||||
//TODO: Look at camera movement -> Not rly smooth. Weird drag
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user