skip to content
Orx Learning
User Tools
Admin
Log In
Site Tools
Search
Tools
Show page
Old revisions
Export to PDF
Backlinks
Recent Changes
Media Manager
Sitemap
Log In
>
Recent Changes
Media Manager
Sitemap
Trace:
Welcome
Beginner's Guide
Config
Examples
Tutorials
en:examples:objects:keep_object_facing_mouse
====== Keep an Object facing the Mouse Position ====== Good for weapons that fire in the direction of the mouse ===== Resource ===== {{ examples:objects:arrow.png |}} ===== Config ===== <code=ini> [Arrow] Graphic = @ Texture = arrow.png Pivot = center Position = (0, 0, 0) </code> ===== Code ===== <code=c> orxVECTOR arrowPosition = orxVECTOR_0; orxObject_GetPosition(arrow, &arrowPosition); orxVECTOR mousePosition = orxVECTOR_0; orxMouse_GetPosition(&mousePosition); orxRender_GetWorldPosition(&mousePosition, orxNULL, &mousePosition); orxVECTOR direction = orxVECTOR_0; orxVector_Add(&direction, &arrowPosition, &mousePosition); orxFLOAT angle = orxMath_ATan(direction.fY, direction.fX); orxObject_SetRotation(arrow, angle); </code> ===== See also ===== [[en:examples:maths:convert_vector_to_radian_angle|Convert a Vector to an Angle (radians)]]
en/examples/objects/keep_object_facing_mouse.txt
ยท Last modified: 2025/09/30 17:26 (9 months ago) by
127.0.0.1
Page Tools
Show page
Old revisions
Backlinks
Export to PDF
Rename Page
Back to top