Precise position detection

Hi everybody,

I’m making a 3d tile based game, and I have some characters walking on tiles.
I wan’t them to be physics, so I just tell them “walk in front of you” until you hit a trigger and make an action.

But the thing is, I want to check an action exactly when the character is in the center of the tile.

But because he’s walking with a speed, I’m not gonna be able to be always on the center of the tile on a frame.

Do you have a solution ?
With triggers will be best for me

Thanks !

I agree with andyrev, currently I have 10 generations of parents connected by joints in my rope. When I try to move the bottom one it can go waaaay beyond 1 but it's position is 1.396984E-09 ... %-) suddenly it can jump to -1.396984E-09 when its at the bounds of the joint without even noticeable change in position

Ah, the reason they're most likely all returning the same is that the centre of the object is actually at 0,0,0 but the mesh is displaced. So Unity doesn't return the meshes location but the position of the object. So you'd need to go into your 3D editing software and set all pivots to the centre of the objects. Its stupid how it does that but it's just how it is

For nested objects, transform.position ABSOLUTELY gets the parent position.

2 Answers

2

If you cross over the center during a frame, it is impossible. You will most likely always be either side of it, unless you’re walking very slowly. A small trigger box or sphere relative to the size of the tile, but as large as the distance travelled in 1 frame should do it.

Hum there is no solution other than that ?
I can make a tiny trigger for the tile, but I have to make a tiny trigger for the character too, and that will not be exactly precise …

If someone has made something or has an other solution I’m happy to hear :slight_smile:

Thanks !