Find Renderer Attached To Parent Object Runtime

Hi guys,

I have hit a wall trying to find the renderer to my other player.

Im developing a multiplayer game and need to access the other players mesh renderer then swap the shader. I have tried a number of things but non seem to work i keep getting renderer is null unless i manually drag the renderer in at runtime…

The renderer sits on the players mesh in the parent.

Here is what i have so far.

using UnityEngine;
using System.Collections;

public class KeepShader : MonoBehaviour {

	public Shader shader;
	public Renderer rend;
	public GameObject remotePlayer;

	void Update() {

		remotePlayer = GameObject.FindGameObjectWithTag("Player");
		remotePlayer.GetComponentInParent<Renderer>();
		rend.material.shader = shader;

	}
}

I know the rend reference to the renderer is obviously null in this example but i just can not work out how to access it in the parent at runtime and assign the rend, Any help appreciated guys.

I have read multiple examples and the unity documents but nothing seems to work.

Thanks andzq for the initial answer which helped me solve the question which i just needed to adjust to my needs. i did the following to find the mesh within the parent… rend = remotePlayer.transform.parent.GetComponentInChildren();