Search the Community
Showing results for tags 'parent'.
Found 3 results
I have a gun script in which I have declared Now I wanna assign the weaponCamera of gun script from its parent's parent's to its parent(MainCamera). Means like this FPSController>Lean(empty gameobject)>MainCamera(i wanna assign this)>Body_1(gameobject)>Arms(gameobject)>M4A1. FPS controller>Soldier. I dont wanna assign camera manually to inspector because I instantiate clone of m4 gameobejct. Similarly I have declared I wanna assign this gameobject from FPSController's child to GameObject of GunScript.(public GameObject Soldier;) I know the question is pretty hard(or may i dont know how to ask questions like this). I tried various codes like : But it didnt work! Im stuck w/ it since Monday. Don't make comments on my english. NVM!
I'm trying to make it so that a Photon Instantiated object becomes a child of a transform. I know how to set the parent locally, but over the network the object just stays in place. Here's what I have so far- GameObject hat = (GameObject)PhotonNetwork.Instantiate (hatName, head.position, head.rotation, 0); hat.transform.parent = head; Sorry if this is way out of the ball park of what I need to do. I didn't think I'd need any remote calls or anything too fancy
OK so I am currently working on multiplayer of my game. I have added a multiplayer 'gun' and would like to set this prefab a child of the player parent WITHOUT ACTUALLY SETTING IT AS A PARENT. So what I'd need to do is somehow 'simulate' the child-parent relationship without setting the parent. I've tried setting the position & eulerAngles to the parent counterpart, but of course the child-parent relationship is way more complicated. For instance, in my script where I just set the position & eulerAngles = the parent, the position will move with the parent and so does the rotation, but since my weapon 'sticks' out a bit, the rotation is messed up. It is hard to explain, but I will provide a few images for the sake of explanation. So here is an image of before turning with the parent-child simulation, the smaller gun is the example here. The larger weapon with the arms are just there for a reference. Here is an image of after I turn slightly to the right: So as you can see, the weapon turns accordingly to its parent, but it doesn't REALLY simulate the parent-child relation. Any help is appreciated. Thanks in advance, william9518