Cassandra Posted March 16, 2013 Posted March 16, 2013 How to create objects on the ground rather than the pivot?
Jaysds1 Posted March 16, 2013 Posted March 16, 2013 Sorry, I'm not sure what a pivot is, can you tell me what it is please?
Cassandra Posted March 16, 2013 Author Posted March 16, 2013 Sorry, I'm not sure what a pivot is, can you tell me what it is please? Well whenever I try to create an object on player's position, it creates that object on the pivot(center) of the player rather than the ground.
DNL291 Posted March 16, 2013 Posted March 16, 2013 Subtract a small value of position 'z' of the object (setElementPosition) or create it by subtracting a small value of object height ('z' position). If you are using the attachElements function, do the same thing in the function argument.
Cassandra Posted March 16, 2013 Author Posted March 16, 2013 Subtract a small value of position 'z' of the object (setElementPosition) or create it by subtracting a small value of object height ('z' position).If you are using the attachElements function, do the same thing in the function argument. I did but sometimes it goes under the ground. Thanks for your help though.
Cassandra Posted March 16, 2013 Author Posted March 16, 2013 Sure, here you go. createObject(2060, transform[1], transform[2], transform[3] - 0.875) The transform table stores player's x, y and z position. Edit: There should be a way to get the ground's position the player (or certain entity) is upon.
DNL291 Posted March 16, 2013 Posted March 16, 2013 Is client-side code? If it is, use getGroundPosition function (See this function on MTA Wiki).
50p Posted March 16, 2013 Posted March 16, 2013 Sure, here you go. createObject(2060, transform[1], transform[2], transform[3] - 0.875) The transform table stores player's x, y and z position. Edit: There should be a way to get the ground's position the player (or certain entity) is upon. This looks fine to me. Player is roughly 2units high, so your code would work fine. If your objects gets created underground then the model's pivot point is higher than you'd expect it to be. Even if the player is crouching his position is still at the same spot, this is also the reason why you can't crouch underneath other environment models (it's not just collision that's causing you not being able to crouch underneath objects). Your code is fine, but like DNL291 said, you can use getGroundPosition to get accurate ground position or processLineOfSight.
Cassandra Posted March 16, 2013 Author Posted March 16, 2013 Sure, here you go. createObject(2060, transform[1], transform[2], transform[3] - 0.875) The transform table stores player's x, y and z position. Edit: There should be a way to get the ground's position the player (or certain entity) is upon. This looks fine to me. Player is roughly 2units high, so your code would work fine. If your objects gets created underground then the model's pivot point is higher than you'd expect it to be. Even if the player is crouching his position is still at the same spot, this is also the reason why you can't crouch underneath other environment models (it's not just collision that's causing you not being able to crouch underneath objects). Your code is fine, but like DNL291 said, you can use getGroundPosition to get accurate ground position or processLineOfSight. Thanks for your input. I'm using custom skin models which I've created on Maya and find out the problem that the origin point starts from the head rather than the center. Thanks!
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