Hello, i hope that someone can give a hand of how to do it. I'm using a character controller as a player, but since i'm thinking about to switch to a rigidbody with "isKinematic" flag on, and turns it off when i need physics to run on my player. What i'm traying to do right now is to make the player pick up a item and hold in his hand. So i think that i could add a hinge to the player rigidbody dynamically. Is it possible? Do you guys have any sugestions of how to do this?
Make the character look like they are picking up the object? Or actually pickup an object after running over it? Make it look like it's picking it up... 1) Animate it in your 3D program and call the animation 2) If your character is made up of parts animate it using the Unity animation tool 3) If your character is made up of parts animate it using script Picking it up. Add a box collider to your object and then add a script to your character controller Code (csharp): void OnTriggerEnter(Collider collider) { [INDENT] if (collider.tag == "Gun") { [INDENT] givePlayerGun(); [/INDENT] } [/INDENT] }
The thing is, how do i add the object to the player? Im working only with the script part, with no animation or anything. My player is a ball and the item is a cube. I want the sphere to hold the cube. Like, attaching to it. How would i "givePlayerGun();" in my situation?
maybe you could state the position you want the cube to be, like right in front of the sphere. or you could create an empty object, once the sphere collides with the cube, the cube moves to that empty objects position. while the empty object should be a child of the sphere, therefore following it.
Try something like this: Code (csharp): cube.transform.parent = sphere.transform sphere.transform.localPosition = new Vector3(1,1,1);