Jump to content

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


Cassandra

Recommended Posts

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

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

Posted

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.

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

Posted
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!

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