Jump to content

Some mathz


Recommended Posts

So, as my math isn't so good as i can get it, i wanna ask it from here.

So, i have done that when a vehicele hits marker, the marker move. But, i need to move the marker ALWAYS to the right side of vehicle. So, when i hit it from north, it goes to the left side of vehicle, when i hit south, it goes left side.. i hope u understand. And.. i dont have no idea how to make that. some rotations and positions .. ? :S

Link to post

You could use a matrix to do this on client side

However, you could also do this:

-- "vehicle" is the car that hit your marker 
-- "marker" is the marker that got hit (obviously) 
px,py,pz = getElementPosition(vehicle) 
rx,ry,rz = getElementRotation(vehicle) 
rz = rz -- change this to "rz = rz + 180" if you wish to move the marker to the other side of the car 
distanceFromVehicle = 7 -- how far away from the vehicle should the marker be 
mx = px + math.cos(math.rad(rz)) * distanceFromVehicle 
my = py + math.sin(math.rad(rz)) * distanceFromVehicle 
mz = pz 

Probably not the best code, but it should get the job done

Link to post

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