- Home /
Make a Sprite visible
I am making a 2d game where a gun is a pickup. The gun is a sprite on the ground with a collider to destroy it on entry. I am having a problem with displaying the gun on the characters arm. I have a child of the player named arm which follows the mouse and i want to enable a sprite on the arm when this object is picked up. I cant figure out the code for this.
Answer by lloladin · Jun 23, 2015 at 09:19 AM
the way i solved this in my game is by adding a child to my gun with the texture then spawning the gun on the player/arm that way you can just move the texture around til you think it fits if you dont know how to spawn an object on the players arm you do it like this
public Transform Arm;
public GameObject Gun;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
Instantiate (Gun, Arm.position, Arm.rotation);
}
this script will spawn the gameobject gun on arms position
Your answer
Follow this Question
Related Questions
Create an invisible area behind 2D objects. 2 Answers
Sprite not visible from behind 0 Answers
Detect if sprite is visible or not 3 Answers