- Home /
How can a player push an object?
public GameObject player;
void OnCollisionStay(Collision player) { GetComponent().Addforce (new Vector3 ( 0, 0, 0)); }
It works but then it didn't work for some reason, could you tell me why. And I want to know a direction that can push an object anywhere in the direction.
Answer by Vipertex13 · Apr 09, 2020 at 03:07 AM
Hello!
To push an object, add a rigid body to the object and make the mass to 1 and put the mass of the player to like 100 then the object will be pushed by the player
Answer by GraceBelt123 · Apr 09, 2020 at 05:10 AM
it is not working, I can't seem to push an object. I did with Player mass 100 and an object mass 1.
Is there a box collider and a mesh render on both objects.
I just tried this and it worked fine.
Answer by JustAbhi · Apr 09, 2020 at 01:16 PM
try increasing the velocity or speed of player and decreasing the drag of object to push. Hope it helps.
Answer by azerty0220pl · Apr 09, 2020 at 01:23 PM
Changing the physic material of the floor worked better for me. Setting Dynamic and Static Friction to 0.1 and setting Friction Combine to multiply works good even if the mass of the player is the same as object's.
Answer by Dealzu-The-Wikid · Apr 09, 2020 at 03:20 PM
Make sure that isKinematic is not checked and isTrigger on your collider is not checked. Both the player and the object need a rigidbody.