- Home /
Cannot Hide Player
Hi, I want to hide a gameobject, to make it feel like it if it is inside a Tank, I have called, a function to do it when character rides the tank:
player.GetComponent("ThirdPersonController").SendMessage("HidePlayer");
And Hide function it's the following:
function HidePlayer()
{
GameObject.Find("rootJoint").GetComponent(SkinnedMeshRenderer).enabled = false; // stop rendering the player.
isControllable = false; // disable player controls.
}
But I have this next error, and I don't know what it's missing, character and tank are in play, it's something about "rootJoint" ? :
NullReferenceException
ThirdPersonController.HidePlayer () (at Assets/Scripts/Player/ThirdPersonController.js:96)
UnityEngine.Component:SendMessage(String)
ThirdPersonController:ThirdPersonController$SendMessage$System.String(Object, Object[])
UnityScript.Lang.UnityRuntimeServices:Invoke(Object, String, Object[], Type)
Tank:Update() (at Assets/nuevo/Scripts/Tank.js:37)
That makes reference to this line:
GameObject.Find("rootJoint").GetComponent(SkinnedMeshRenderer).enabled = false; // stop rendering the player.
Hope you could help me Lot of thanks in advance
GameObject.Find("rootJoint") locates the game object named rootJoint. Is your player character named rootJoint?
Answer by hrc706 · Jan 25, 2013 at 10:57 AM
Just change from "rootJoint" to "Lerpz" or something else you named the robot, because in the new version of Unity the SkinnedMeshRenderer Component has been moved to here. Good Luck! :-)
Your answer
Follow this Question
Related Questions
hide child object script - help 1 Answer
Hide scripts from the Project View 2 Answers
HIDE CHILD script - help 3 Answers
How to Hide the GUI when time.scale = 1 again 1 Answer
Pause menu script, mouse not hiding 1 Answer