- Home /
How to make Vector Position Of Character?
I have this line of code that plays an effect, I'm trying to make the effect play at the position of my Character, how do I do this? I know I need to change the coordinates of x, y and z but I just don't know what too. if(GUI.Button(Rect(20, 30, buttonRect.width, buttonRect.height), "Type01")){ Instantiate(Type01, Vector3(0, 5,0), Quaternion.identity);
Comment
Answer by JustFun · Aug 11, 2014 at 06:20 PM
Modify your script in such way:
public class YourClassName : MonoBehaviour
{
public Transform charPosition;
.....
if(GUI.Button(new Rect(20, 30, buttonRect.width, buttonRect.height), "Type01"))
{
Instantiate(Type01, charPosition.position, Quaternion.identity);
}
In Unity editor drag you character object from Hierarchy tab into charPosition field, which will appear in your script component in Inspector tab.