Jump to content

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


Cassandra

Recommended Posts

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.

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

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