Z4Zy Posted May 24, 2018 Share Posted May 24, 2018 Hi guys..!! Now I am finding a way, how to create an arrow [ "Down arrow" pickup :- 1318 ] that every-time targeting one position. Like... there is an arrow on player's head and it leads the player to reach a position. So that arrow always target one position. What should i do to set the arrow's target to one position ?? Can you help me ?? Link to comment
Dzsozi (h03) Posted May 24, 2018 Share Posted May 24, 2018 Maybe these functions can help you. I don't know which way you want to do your thing, 2D or 3D. https://wiki.multitheftauto.com/wiki/FindRotation3D - for a 3D pickup https://wiki.multitheftauto.com/wiki/GetScreenRotationFromWorldPosition - for a dxDraw image 1 Link to comment
Z4Zy Posted May 24, 2018 Author Share Posted May 24, 2018 first, thank you @Dzsozi (h03) for mentioned the functions to me. And I created a simple code using "findRotation3D". That code does not function successfully. Code mentioned bellow. local object = createObject( 1318, 0, 0, 0 ) addEventHandler("onClientRender",getRootElement(), function () local px, py, pz = getElementPosition(getLocalPlayer()) local rx, ry, rz = findRotation3D( px, py, pz, 0, 0, 2 ) local ax, ay, az = getElementPosition(getLocalPlayer()) setElementRotation( object, rx, ry, rz ) setElementPosition( object, ax, ay, az + 2 ) end ) The "object" is always present in player's Z co-ordinate + 2. But, it's rotation is malfunctioning. Means, the object's rotation is not rx, ry, rz. What is the reason for that ?? What's the wrong in code ?? Link to comment
Z4Zy Posted May 25, 2018 Author Share Posted May 25, 2018 (edited) I created another code that create 2 objects as, 1st is vehicle 587 and 2nd is pickup 1318. And apply a function that exist "findRotation3D" function, to rotate the car faced to pickup's direction. As Follows, Client Side :- local object1 = createVehicle( 587, 2.67369, 23.92969, 3 ) local object2 = createObject( 1318, 0, 0, 4 ) addEventHandler("onClientResourceStart",resourceRoot, function () local x1, y1, z1 = getElementPosition( object1 ) local x2, y2, z2 = getElementPosition( object2 ) local rx, ry, rz = findRotation3D( x1, y1, z1, x2, y2, z2 ) setElementRotation( object1, rx, ry, rz ) end ) This code works fine. Means, the car is facing to the pickup's direction successfully. This code and previous code, both are created on client side. Why is my previous code does not worked ?? is the problem in pickups ?? i need to make that previous code work. Help me to fix previous code. Please Help...!! Edited May 25, 2018 by DeadthStrock Link to comment
Dzsozi (h03) Posted May 25, 2018 Share Posted May 25, 2018 I am not sure, but try changing the rotation by adding + 90 or so values, since the default object rotation might not fit your needs. setElementRotation( object, rx, ry, rz + 90 ) Link to comment
Z4Zy Posted May 25, 2018 Author Share Posted May 25, 2018 aahh... I've tried that thing.., but I couldn't see any change in the arrow. it remains downward. Link to comment
Z4Zy Posted May 26, 2018 Author Share Posted May 26, 2018 aren't there any alternative way to fix that code ?? Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now