Answer the question
In order to leave comments, you need to log in
How did changing the transform of an object not change the location of the children relative to the object?
Unity2D. I'm making a gun. The gun has a FirePoint and is near the muzzle, but when the player picks up the gun, the transform of the gun is equal to the player's transform. But there is one problem. FirePoint's transform is also equal to the player's transform. How to make FirePoint not change its location relative to the gun?
Here is the transform change code:
public GameObject target;
public Vector3 Pos;
void Update()
{
transform.position = target.transform.position + Pos; //Pos делает так, чтобы пистолет не торчал прямо из игрока(может есть какой-то не костыльный способ?)
gunsprite.flipX = charactersprite.flipX;
if (gunsprite.flipX == true)
{
Pos = new Vector3(-0.5F, Pos.y, Pos.z);//Примерно то же самое что и Pos
}
else
{
Pos = new Vector3(0.7F, Pos.y, Pos.z);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question