Skip to content

Commit

Permalink
gravity and kinematics
Browse files Browse the repository at this point in the history
turned off gravity when button is pressed up (released) so it falls to the ground. Otherwise it will float in space. Turned kinematic on on button down so objects don't knock off my food from hand before I release and then turned it back off when I do release
  • Loading branch information
mayraazamora committed Mar 20, 2023
1 parent 0cacae9 commit 2b27e22
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 31 deletions.
10 changes: 3 additions & 7 deletions Assets/Scripts/ObjectThrower.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ public class ObjectThrower : MonoBehaviour

private Rigidbody heldObject;

void Start()
{

}

// Update is called once per frame
void Update()
{
Expand All @@ -25,16 +20,17 @@ void Update()

//Spawn the randomly choosen food prefab
heldObject = Instantiate(randomObject, transform.position, transform.rotation, transform);

heldObject.useGravity = false;

heldObject.isKinematic = true;
}

// Check if the hands trigger button has been released
if (Input.GetButtonUp(triggerName))
{
// Detach the food object from the hand
heldObject.transform.SetParent(null);
heldObject.useGravity = true;
heldObject.isKinematic = false;

// Apply a force to the food object to throw it
}
Expand Down
1 change: 0 additions & 1 deletion Assets/Scripts/heldObject.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Assets/Scripts/heldObject.cs.meta

This file was deleted.

1 change: 0 additions & 1 deletion Assets/Scripts/heldObject1.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Assets/Scripts/heldObject1.cs.meta

This file was deleted.

0 comments on commit 2b27e22

Please sign in to comment.