Jump to content

Attach Element To Element Help!


Woovie

Recommended Posts

http://development.mtasa.com/index.php?title=GetPlayerContactElement

Get the position of that element and the player etc. etc.

I don't think that's what he needs, it's not that easy as it sounds :P he'd like to attach the player so it remains in the same position

it involves rotations and trigonometry, I suggest looking for snippets on the Internet, you might find something

Edited by Guest
Link to comment
I never claimed to give the final answer, I just point people in the right direction 8)

lol it's cool :D

what I meant is that if you only find the positions and get the differences and use them as offsets for attachElementToElement, it will probably attach you in the wrong position

I suck at explaining but I'll try anyway, in this pic the square is a vehicle and the dot is the player:

67079440xh5.png

(pic a) the vehicle's position and rotation is ( 0, 0, 0 ) the player is located a little bit to the south, ( 0, -1, 0 ) which means

newX = x2 - x1 = 0 
newY = y2 - y1 = -1 
newZ =z2 - z1 = 0 

( 0, -1, 0 ) would be correct but if the vehicle is rotated 90 degrees to the right (pic b) the offsets would be..

newX = x2 - x1 = -1 
newY = y2 - y1 = 0 
newZ =z2 - z1 = 0 

and the player would be attached to the left of the vehicle because attachElementToElement still expects ( 0, -1, 0 )

you need something that calculates the right offsets regardless of the vehicles rotation :P

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