|
Hi i was wondering what the best way to determine which way a character should rotate when it its ray returns a hit. I have thought about casting two rays so that the one least close to the collier determines the direction, but i cant figure out how to code the ray direction. any help is very appreciated. Thanks Brian
(comments are locked)
|
|
You can cast a ray in a specific direction like this:
Vector3.forward could be any Vector direction you wish. Sorry my fault, i've got snow blindness from staring at too much code.
Feb 26 '10 at 05:05 PM
sacredgeometry
:) heh we just went through deleting comments at the same time... so yeh, no worries
Feb 26 '10 at 05:06 PM
Motionreactor
Oh, btw.. I remembered this awesome reference on autonomous steering: http://www.red3d.com/cwr/steer/
Feb 26 '10 at 05:35 PM
Motionreactor
Thank you so much for the link that will help lots, currently my little guy is getting stuck in corners :D... an easy fix but i think theres a lot worse to come.
Feb 26 '10 at 09:00 PM
sacredgeometry
heh, yeh I've done a little bit of this kind of thing before and experienced the same thing. There's always problem cases like that, but that's half the fun of it, making it smarter.
Feb 27 '10 at 02:38 AM
Motionreactor
(comments are locked)
|
|
This steering behavior and others are implemented in UnitySteer, which is a port of Craig Reynolds' OpenSteer (the reference on autonomous steering that MotionReactor linked to is Reynolds' as well). The function you'd be interested on is steerToAvoidObstacles, or maybe steerToAvoidNeighbors. Once you begin getting into the fnier points of steering, such as a group of vehicles attempting to behave reasonably when encountering each other, you might want to look at Mikko Mononen's Project Cane, as well the other articles he has posted on his site on the topic of velocity obstacles. To close, I don't actually recommend you use raycasting for every aspect of navigation. For static areas like walls, a navigation mesh and AngryAnt's Path is a better option. Nice. I didn't know UnitySteer existed, Awesome! Thanks.
Feb 27 '10 at 02:49 PM
Motionreactor
I will read, download and explore those libraries as soon as i have the time, and as always any help is appreciated so thank you. Peace Brian
Feb 28 '10 at 01:07 AM
sacredgeometry
Those links are outdated!! can you guys give a new link?
Aug 27 '12 at 05:20 PM
Karsnen
(comments are locked)
|
|
Having done a "bit" of this stuff over the years, I agree with Ricardo's assessment cautioning you against extensive use of ray casting for navigation. The corner problem that you are encountering is a perfect example where ray casting, and more generally, purely reactive steering becomes problematic. For example, in corners, as you are turning away from the corner you typically wind up moving closer to one side of the corner or the other. A purely reactive solution (e.g., turn in the direction of most space) will cause you to move back into the corner and cause the oscillation you are seeing. As Ricardo mentions, Mikko Mononen's website has a superb set of links to the latest papers in the field, most of which are based on a concept known as velocity objects (and variants such as reciprocal velocity objects). The big idea of velocity objects is that, based on the relative motion of 2 objects, it divides velocity space into those velocities (speed and direction) that are collision-free over some time horizon, and those velocities that will result in a collision over that time horizon. When tied to a planner that provides, in effect, a preferred velocity (namely one that will get you to the goal position), you can arrive at the closest velocity to your preferred velocity that will still be collision-free over the time horizon. At the end of the day you need a robust local steering (collision-avoidance) system as well as a nav. planner of some sort.
(comments are locked)
|

