i was looking at the bike-zone detection it looks strange and seems to be splitting a zone into 42 segments then checking if bike intersects one of these segments
maybe this was done for speed ? im not sure
im not great at math but i think something like this should work
distance=sqrt(sqr(abs(bikeX - zoneX)) + sqr(abs(bikeY - zoneY))) - zoneRadius
distance will be > 0 if youre outside the zone and <= 0 if youre inside the zone
zone detection
Re: zone detection
just thinking you could remove the square root and square the radius should execute faster
distance=sqr(abs(bikeX - zoneX)) + sqr(abs(bikeY - zoneY)) - sqr(zoneRadius)
distance=sqr(abs(bikeX - zoneX)) + sqr(abs(bikeY - zoneY)) - sqr(zoneRadius)
Re: zone detection
Er, are you referring to the CYCLE_ZONES_AVOID code ?
The actual bit detecting if a player is inside a zone or not is available within InteractWith: Which, thinking about it, I'm not quite sure why it'd trigger OnEnter every time. Maybe because there's no OnInside callback here? Meh.
This is a hack for detecting if the AIs are heading towards a zone, NOT for detecting whether every player is in the zone. It indeed isn't the best but an improvement over simply checking if an AI is near a zone before attempting to turn away. This will only happen if you have AIs in the game and if the AIs are close enough to the zone anyway; it shouldn't be massively detrimental to performance. (basically, most likely only active in single player)
The actual bit detecting if a player is inside a zone or not is available within InteractWith: Which, thinking about it, I'm not quite sure why it'd trigger OnEnter every time. Maybe because there's no OnInside callback here? Meh.
Re: zone detection
That would be the reason. Development started with just Win and Death zones, where the effect would only trigger once no matter what, that's why the function was called OnEnter and not OnInside. Renaming virtual functions is always a bit of a pain, that's probably why the name then stuck.
Re: zone detection
wouldnt this work to detect if approaching zone perimeter ?
distance=sqr(abs(bikeX - zoneX)) + sqr(abs(bikeY - zoneY)) - sqr(zoneRadius)
zoneDetectRange=sqr(metres)
to avoid zones from outside
if distance < zoneDetectRange then turn
to stay inside zones from inside
if -distance < zoneDetectRange then turn
to both avoid zones if outside and stay inside if already inside
if abs(distance) < zoneDetectRange then turn
distance=sqr(abs(bikeX - zoneX)) + sqr(abs(bikeY - zoneY)) - sqr(zoneRadius)
zoneDetectRange=sqr(metres)
to avoid zones from outside
if distance < zoneDetectRange then turn
to stay inside zones from inside
if -distance < zoneDetectRange then turn
to both avoid zones if outside and stay inside if already inside
if abs(distance) < zoneDetectRange then turn
Re: zone detection
Probably, but it would not detect if the cycle is actually facing the (edge of the) zone, only distance.