Sign in to follow this  
Cassandra

Create objects on the ground and not the player's pivot

Recommended Posts

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.

Share this post


Link to post

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.

Share this post


Link to post
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.

Share this post


Link to post

You can show the code you tried so we can help.

Share this post


Link to post

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.

Share this post


Link to post
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.

Share this post


Link to post
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!

Share this post


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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.