Unity: Throwable Objects

Changed throw button from D to F
This commit is contained in:
Santi 2024-04-28 17:20:37 +01:00
parent d68f3bd970
commit 91e43f9b3a
2 changed files with 7 additions and 7 deletions

View File

@ -27,9 +27,13 @@ public class Movement : MonoBehaviour
if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0) if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)
{ {
Quaternion ToRotation = Quaternion.LookRotation(new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"))); Quaternion ToRotation = Quaternion.LookRotation(new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")));
throwForce.throwForce = 7.5f; throwForce.throwForce = 8.5f;
transform.rotation = Quaternion.RotateTowards(transform.rotation, ToRotation, turnSpeed * Time.deltaTime); transform.rotation = Quaternion.RotateTowards(transform.rotation, ToRotation, turnSpeed * Time.deltaTime);
} }
else
{
throwForce.throwForce = 4.0f;
}
moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
@ -41,10 +45,6 @@ public class Movement : MonoBehaviour
{ {
throwForce.throwForce = 20.0f; throwForce.throwForce = 20.0f;
} }
else
{
throwForce.throwForce = 5.0f;
}
} }
else else
{ {

View File

@ -20,12 +20,12 @@ public class PickUpObject : MonoBehaviour
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
if(insideTrigger && Input.GetKeyDown(KeyCode.D) && !carrying) if(insideTrigger && Input.GetKeyDown(KeyCode.F) && !carrying)
{ {
carrying = true; carrying = true;
carriableObject.GetComponent<Rigidbody>().isKinematic = true; carriableObject.GetComponent<Rigidbody>().isKinematic = true;
} }
else if(carrying && Input.GetKeyDown(KeyCode.D)) else if(carrying && Input.GetKeyDown(KeyCode.F))
{ {
carrying = false; carrying = false;
carriableObject.GetComponent<Rigidbody>().isKinematic = false; carriableObject.GetComponent<Rigidbody>().isKinematic = false;