Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I’ve found a lot of information on passing parameters from one script to another when a game object is present in the hierarchy. My problem is that my Transform object is created on the fly using Instantiate(myPrefab). Is there any way to access the position of myPrefab game object from another script?

In the code you see that I’ve tried to access the class ScanManager but while it is public, Unity is looking for me to drop a scanmanager type in the box but there is nothing I can actually put in the box from my project because in the hierarchy I don’t have a 3d object. I can not have one since the object I need will be created and positioned later. I’ve tried to access the variables using other methodologies but nothing worked so far.


Thank you for your help

What I have tried:

public ScanManager scanManager;
    private Transform boxOn;

    public Animator animator;

    void Start()
    {
        scanManager.InstanciateObjectOnSurface();
        boxOn.position = scanManager.couchP.position;

        keywordActions.Add("Reset", GoHome);
        
    }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900