Hi guys
I'm, coding a 3D top down shooter and I want the player to fire in a direction relative to where the mouse and avatar are in screen space.
I thought once I have the two positions I can calculate an angle between them and have the player shoot in that direction.
But I don't know how to convert the world position of the avatar to it's position on screen.
Any insight would be greatly appreciated.
Cheers!
Rob
Word co-ords to screen co-ords
For D3DX there's D3DXVec3Project and D3DXVec3Unproject, to go from world coords to screencords and screencoords to world coords.
For XNAMath the functions are called XMVector3Project and XMVector3Unproject, and for C# XNA there's Viewport.Project and Viewport.Unproject.
For XNAMath the functions are called XMVector3Project and XMVector3Unproject, and for C# XNA there's Viewport.Project and Viewport.Unproject.
For D3DX there's D3DXVec3Project and D3DXVec3Unproject, to go from world coords to screencords and screencoords to world coords.
For XNAMath the functions are called XMVector3Project and XMVector3Unproject, and for C# XNA there's Viewport.Project and Viewport.Unproject.
PERFECT!
Thank you very much :-)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement