December 8, 2016 at 13:02 #16895Kirill PervushynParticipant
We have a car – object that has finite radius of turn (not infinitely small).
We teached it to turn by curve when it moves, but when it stays on the spot it still goes right where the waypoint says – no turning happens.
What we want to have:
1) Unit has the Turn-Sector in front of him – the angle where velocity vector can be applied. Let’s say it is 45 degrees left and 45 degrees right from unit’s forward
2) If direction to waypoint lays within this sector (let’s say 30 degrees) then velocity vector is applied normally
3) But if direction to waypoint goes out of this sector (135 degrees) then velocity vector is applied at maximum allowed degree from the Turn-Sector (45 degrees).
This naturally occurs while unit is on move as it cannot change velocity vector fast.
But if initial velocity vector was 0, then after waypoint appeared new velocity vector is applied right in its direction.
So the question is: how we achieve behaviour descried in 1)-3) ?
Thanks in advanceDecember 8, 2016 at 13:14 #16897GeminiorKeymaster
In the Steerable Unit component all steering input is gathered and passed on to an implementation of the IMoveUnits interface. The default implementation just moves the unit according to the desired velocity.
So what you need to do is write your own implementation of IMoveUnits, where you implement the logic you described. Implement it as a MonoBehavior and attach it to the unit.
You can find examples of IMoveUnits implementations in both the Steerable Unit component itself, and in the examples project.December 8, 2016 at 18:19 #16906Kirill PervushynParticipant
Now we’ll teach unit to use reverse when he is in front of the wall – I guess we implement it in IMoveUnits as well.
Thank you, GeminiorDecember 9, 2016 at 12:41 #16925
You must be logged in to reply to this topic.