PositionEntity Problem

Blitz3D Forums/Blitz3D Programming/PositionEntity Problem

John Blackledge(Posted 2004) [#1]
You'd think after 2+ years of programming in Blitz I'd have seen everything. Well how about this:

PROBLEM 1: POSITIONENTITY.
Setting the start position of a vehicle; ent is a pivot, and _not_ a child of another entity.
My car was nowhere in sight, so I checked the code:

ex = 723 : ey = 9 ; ex = 392
PositionEntity ent, ex,ey,ez
UpdateWorld()
tempex = EntityX(ent)
tempey = EntityY(ent)
tempez = EntityZ(ent)
; tempex returns 127!
; tempey returns 206!
; tempez returns 392!

After 2 days of frustration I wondered what would happen if I immediately repeated the positioning:
PositionEntity ent, ex,ey,ez
UpdateWorld()
tempex = EntityX(ent)
tempey = EntityY(ent)
tempez = EntityZ(ent)
; tempex,y,z now _sometimes_ return 723,9,392 (the correct values).
But not all the time. It's a 50/50 chance that I will get non-accurate values as I step through the second block of code.
So my cars appear up in the air, or away from the racetrack altogether.
This problem happens whether the parent is a pivot or a sphere.
Can anyone help. This feels just plain insane!

PROBLEM 2: POSITIONENTITY.
I now take it for granted that child entities are not going to stay 'attached' to parent entities.
So every loop I have to do 'PositionEntity car,0,0,0' to 'remind' Blitz to re-attach the child to the parent pivot accurately, or else the car drives along the side of the road, while the pivot drives down the middle.


Rob Farley(Posted 2004) [#2]
Sounds like a collision thing.

Hide your entity before you position it, then show it again.


John Blackledge(Posted 2004) [#3]
Problem appears to be immediately solved. Yippee!
Thanks Rob. This is a good one to remember for the future, and as a general method.

Now, any ideas why child entities don't stay attached to parent entities unless 'refreshed' every loop?


WolRon(Posted 2004) [#4]
They do stay attached, they just get farther away if a collision happens. This is normal.


John Blackledge(Posted 2004) [#5]
Sorry, isn't that a contradiction in terms?
If this is unavoidable, then I can't see the point of child entities - I could just as easily 'align' entities with 'parents' manually.


GitTech(Posted 2004) [#6]

Hide your entity before you position it, then show it again.



Or use ResetEntity()


martonic(Posted 2004) [#7]
Try this:

EntityType your_child,0

If the child is not buffeted by collisions, it should follow along perfectly.


John Blackledge(Posted 2004) [#8]
Actually I do need the children to register collisions, but thanks anyway. It just means that each loop I have to do PositionEntity ent,0,0,0,FALSE for each child, and also the same for my camera which is a child of a pivot - it also needs to register collisions so that it doesn't go through overhangs.
Thanks to all for replying.


Rob Farley(Posted 2004) [#9]
John, the way round this is to use pivots as your children then positionentity your colliding children to the pivot locations entityx(childpivot,true),entityy(childpivot,true),entityz(childpivot,true)

There has been talk in the past about being able to make one super entity from a bunch of children and treat the collisions as one, this way you could get a cube (for example) and stick a pivot on each corner so you'd know which corner hits the ground. As it currently stands the corner child will move, so you've got to manually keep track of where they are to see what's hit.

Bit of a pain in the arse but there it is.


John Blackledge(Posted 2004) [#10]
Thanks, Rob.
Unfortunately I feel that it's one of the points about children/collisions that could have been explained better (or at all) in the manual, thus saving me days of being convinced that it was my fault. But I'm there now, thanks to you all.