简体   繁体   中英

Python Ursina, How can I get the players position?

The title says it all, how can I get a the first person camera controller's position (X, Y, Z) in Python using the Ursina Game Engine? Thanks for any help!

You can use camera.position to get the player's position. If you're using the FirstPersonController , you can simply do:

controller = FirstPersonController()
controller.position

Since FirstPersonController is an entity.

Just use entity.position . You can get the position of every entity, including the player.

Make.


player = Entity(model='cube', position=(0,10,0)

player_pos = player.position
print(player_pos)

Because position is an attribute of Entity, you can get that value and print it.

Bonus

You can change the player to FPC and you will get the same result.

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