简体   繁体   中英

Display Object in front of player without considering its rotation

I can show another object in front of my player using this simple line of code

newPosition =player.transform.position+player.transform.forward * distance

but how can i restrict it to always show in the same position(but in front of player) no matter what is the rotation of my player ?

When you rotate gameobject transform.forward always changes.Because of you are using local values. But you need the use word values for this.

newPosition =player.transform.position+Vector3.forward * distance

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM