Jump to content

Calculate the rotation.


IIYAMA

Recommended Posts

  • Moderators

Hello,

I got a question,

How can I calculate a rotation of something without using "getElementRotation".

I have 1 ped that is watching an object.

This object will be moving arround the ped.

The ped will change it's rotation when the object is moving "setElementRotation".

It isn't in the sample, because this ped will be a player.

--

I have 2 locations. The one of the ped and the one of the object.

This is a sample:

  
local ped = createPed ( 63, 0, 0, 3 ) 
local object = createObject ( 1337, 5540.6654, 1020.55122, 1240.545, 90, 0, 0 ) 
  
function setrotation() 
    local rotate = getPedRotation(ped) 
    setPedRotation ( ped, rotate+40 ) 
end 
  
setTimer(setrotation, 100, 0) 
  
  
-- how can I calculate the rotation of a ped when I have the locations of the direction were the ped is watching to. 
local x,y,z = getElementPosition( ped ) 
local x2,y2,z2 = getElementPosition( object ) 
  

NO USING getElementRotation, because I have to compare with that one.

Link to comment
  • 2 weeks later...

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...