Page MenuHome

Character walkDirection ADD mode -#INF error
Closed, DuplicatePublic


Category: Physics

It appears that if you set two character motion controllers on the same axis with opposite signs at the same time (ADD) it will sometimes result in an infinite vector for walk direction (and thus worldPosition). In the test file hold (W then S) or (S then W) or (A then D) (for some reason D then A doesn't do this).
Showing the console will show the outcome.

Event Timeline

Might I also add the following points (primarily so that I don't forget and If you have time you could check it out):
1) Changing the substeps for physics changes the fall speed
2) For some reason the Bullet gravity is set to 3Gs in the character controller defaults in Extern/Bullet2
3) The falling doesn't seem to be very smooth at all.

*also it doesn't return a reference to the walkDirection in the wrapper*, only a copy of the value, which seems inconsistent

As of r54738 you will no longer get the -#INF issues. However, the actual results will depend on the order of when the actuators are fired. For example, if the current walk direction is <1, 0, 0> we can have two possibilities. We'll have actuator A add <1, 0, 0> to the walk direction and B add <-1, 0, 0> to the actuator. If A goes off first, the result will be <1, 0, 0> (the result is normalized) followed by <0, 0, 0> and the character stops. Otherwise if B goes first, then we get <0, 0, 0> first then <1, 0, 0> second and the character keeps moving in the same direction. I'm not sure how to solve this problem, or if it's something that should be solved. So, I'm open to some feedback on how to tackle this.

As for the other issues you mentioned:
1) This is already noted in another bug report somewhere, and is a Bullet issue.
2) Again, this is a Bullet thing.
3) This seems rather subjective, and I haven't had too many problems here.
4) All the character wrapper has is a copy; I can make sure this is noted in the docs.

This is always an issue with character controllers. Except your example is incorrect I believe(?)
If the direction has an x component of 1.0, then A followed by B would equate to: (Start) 1 -> (+A) 2.0 -> (+B) 1.0
However, if you stop the motion at the end of an input, would it be better to involve a callback of some sort that would operate after all logic bricks are executed? This would best demonstrate group behaviour of logic bricks rather than each acting as a self contained component. However, this may break the preconception that all logic bricks have only the smallest dependencies (e.g Collisions -> Bullet)

Actually, the add isn't a straight add. Otherwise, calling the same direction over and over would start to make you go very fast, which is why you get <1, 0, 0> and not <2, 0, 0>.

I see. Well, one possible solution to this would be to register a callback. Each time an actuator processes using ADD it adds the vector to a Set - like data structure stored on the GameObject (Or should it be within the Logic system?). That way only unique vectors are stored. At the end of the logic frame we sum the vectors for a resultant and apply that?