Jump to content

[Help] Arrow that targeting one position


Z4Zy

Recommended Posts

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

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

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 by DeadthStrock
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...