Placing an object in front of the camera

后端 未结 2 1198
陌清茗
陌清茗 2021-02-19 15:11

This should be an easy task, and I have googled it, but I can\'t figure out why any of the examples are working for me.

Basically, I want to place tiles on the ground in

2条回答
  •  粉色の甜心
    2021-02-19 15:44

    You could use the forward vector of the object, something like this:

    public GameObject frontObject;
    public float distance;
    
    void Update () {
        frontObject.transform.position = Camera.main.transform.position + Camera.main.transform.forward * distance;
    }
    

提交回复
热议问题