ricardojmendez / UnitySteer

Steering, obstacle avoidance and path following behaviors for the Unity Game Engine
https://numergent.com/tags/unitysteer/
Other
1.2k stars 275 forks source link

Strange behavior on Evasion when target doesn't move #33

Closed Indiefreaks closed 9 years ago

Indiefreaks commented 9 years ago

Hi Ricardo,

It's me again :P

I have a bizarre behavior with the steerforevasion component when the target isn't moving at all: they kinda flee like fishes :p while I would expect a straight movement instead. I've posted a small video on Youtube to illustrate that. Note that this is valid for all instances I used.

https://youtu.be/2x-lP3VzXZ0

Thanks for letting me know if you see what I could do to remove this behavior.

SonnyAD commented 9 years ago

Hi

I have the same situation too. I have some fighters chasing ships and sometimes the fighters have these movements. I guess it's related to the precision of the prediction. My ships were static so far, now they are moving slowly. I didn't notice so much improvements. Did you try to put the prediction time to 0 on the SteerForEvasion, Philippe? I didn't try.

Cheers, Sonny Alves Dias

Le lun. 27 avr. 2015 à 17:30, Philippe Da Silva notifications@github.com a écrit :

Hi Ricardo,

It's me again :P

I have a bizarre behavior with the steerforevasion component when the target isn't moving at all: they kinda flee like fishes :p while I would expect a straight movement instead. I've posted a small video on Youtube to illustrate that. Note that this is valid for all instances I used.

https://youtu.be/2x-lP3VzXZ0

Thanks for letting me know if you see what I could do to remove this behavior.

— Reply to this email directly or view it on GitHub https://github.com/ricardojmendez/UnitySteer/issues/33.

Indiefreaks commented 9 years ago

The prediction time is actually set to 0 in the video I posted so I don't think that is related. It seems to happens only when at a certain distance from the target. If you look on my video, you'll see that the ship continues in evasion for some distance before actually getting back to another steering behavior and it goes straight...

Might be a precision issue. I'll try to investigate a bit more. Otherwise, I'll have to go for another solution such as randomly defining a flee point and using a SteerForPoint instead...

ricardojmendez commented 9 years ago

@Indiefreaks Do you have a small repro case? Any other behaviors attached to the object? If I had to blindly guess, I'd suggest you start by increasing how often the vehicle updates its steerings (I think the default is 0.1s).

Indiefreaks commented 9 years ago

I made the video so that you can see the other components and their properties (if you pause the video, you'll be able to see them clearly :p)

I'll try the updates property tweak to see if that changes anything.

Indiefreaks commented 9 years ago

Ok, I made the test and reduced the TickedLength value from 0.1 to 0.01 and it made the trick. My spaceships now don't "fish" as before.

However, I may have found a small bug or feature request depending on how you'll interpret it: Modifying the TickedLength value on a TickedVehicle or its subclasses, it won't update the value of the inner TickedObject because the actual Ticked Length is set on the TickedObject.TickLength property when the gameobject is enabled nor when it is modified.

I don't know how this system works so I didn't made a change on the code (especially if it handles multithreading in the background which could lead to even worse bugs if not done properly). Thus, it would be great if the actual values could operate directly at runtime (in the Editor) so that we can test while playing in editor or even change the ticked length at runtime depending on the number of units that we may have to deal with...

Thanks.

ricardojmendez commented 9 years ago

However, I may have found a small bug or feature request depending on how you'll interpret it: Modifying the TickedLength value on a TickedVehicle or its subclasses, it won't update the value of the inner TickedObject because the actual Ticked Length is set on the TickedObject.TickLength property when the gameobject is enabled nor when it is modified.

You are correct, it is set only when the TickedObject is created OnEnable. There is no multithreading, as Unity wouldn't be able to take it, and instead things are handled through a TickedPriorityQueue which means you could just change the value on the TickedObject yourself and the change will take effect after the next time it's ticked (since iirc it's used to set a "next tick time").

Indiefreaks commented 9 years ago

Should I go throught a pull request with some additions to the TickedVehicle class where you'd be able to change the value from the Inspector and see it applied in the TickedObject instance ?

Thanks

ricardojmendez commented 9 years ago

Sure, go ahead. I may not merge it right away, since I want to make sure nothing else breaks, but it'll be useful to have.

Indiefreaks commented 9 years ago

Ok, I'll have a go and let you know about it.

For that, I'll create a new feature request in the ticket system.

Cheers and thanks for the help ;)