Stingray Forum (Read Only)
Welcome to Autodesk’s Stingray Forums. Share your knowledge, ask questions, and explore popular Stingray topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Gameware Navigation & Raycasting

5 REPLIES 5
Reply
Message 1 of 6
kainevg
5292 Views, 5 Replies

Gameware Navigation & Raycasting

Hello once again everyone!

 

The game I am working on requires spaceships to have path finding and avoidance AI so they can fly around obstacles, not run into each other etc..

 

I've read through the API on everything navigation and I've come to the conclusion that Gameware Navigation that's implemented in Stingray is only capable of pathfinding on a plane. Is this correct?

 

I've got a few ideas on how I could accomplish the behaviour I want but I just have a couple of questions. In my mind 3D nav is not that much more difficult than navigating a plane, however it seems using traditional methods such as having nodes over a VERY large map would be a huge performance hit. I was thinking I could potentially have nodes at destinations the spaceship could fly between, however with a dynamically moving map as I would have in space with orbits and moving asteroids etc I believe this method would be out, unless when an object collided with a nav point it disabled it for use... but again I think it will lead to an expensive solution. This basically leaves me with raycasting and local avoidance.

 

My question! In the engine, how expensive is it when I call the ray cast function?

 

Any suggestions for navigating the depths of space?

 

Thanks!

Kaine

 

P.S Feel free to just answer my question about ray casts if you have no suggestions 🙂

5 REPLIES 5
Message 2 of 6
dan.matlack
in reply to: kainevg

Raycasts, like most calls, are not too heavy own their own but as they add up with many objects doing many calls each tick, it will become performance heavy. As far as a 3d space solution to navigation -- this is a good question. You could possibly do multiple planes of navigation a few meters z apart and have the npcs jump from plane to plane somehow ... or maybe there is a way to do 3d nav mesh that I am not aware of. I will reach out to the team and see who knows what. 🙂

______________________________________
Dan Matlack
Senior Content Manager || Games Solutions
Autodesk, Inc.
Message 3 of 6
kainevg
in reply to: dan.matlack

Yeah. I guess I just have no base of reference for what is a considered a lot of calls, I guess it depends on what else is happening in the game.

 

That would be great if you could reach out, when you find the navigation guru, and if as I believe Gameware Navigation can't do flight navigation, could you ask them if they have any suggestions for me to look into? Different ideas are always good!

 

Cheers,

Kaine

Message 4 of 6
devirosnguyen
in reply to: kainevg

Hi Dan, 

 

I have some questions for this problem
1). Single, synchronous raycasts

local foundCollision, collisionPos, distance, normal, actor = stingray.PhysicsWorld.raycast(my_world, start, dir, "closest")

What is "start" parameter?

2). Multiple, asynchronous raycasts

local raycastObj = stingray.PhysicsWorld.make_raycast(my_world, my_raycast_callback, "all", "types", "statics")
raycastObj:cast(start, dirA, length)
raycastObj:cast(start, dirB, length)
...

What is "length" parameter?

 

Thanks

Deviros

Message 5 of 6

@devirosnguyen 

 

"start" stand for the world space starting position of your raycast, "dir" for its direction (usually a normalized vector) and "length" for the maximum distance you want the raycast to look for. In effect, you can reason about raycast as behing a line segment in space. This will provide some spatial culling information to the physics engine, and therefore fastened the raycast call by only testing with the relevant geometry.  

 

@kainevg

 

Navigation is actually 2d "and a half" Smiley Happy in that you can add navigation graph to the navigation mesh. You can even use Navigation with a navigation graph only, and therefore leverage Navigation pathfinding in space if you provide it with a set of connected 3D graph vertices.

 

Albeit, if you are making a 3D space game, you may not even need that. If you are never going to navigate inside a huge space ship (think death star attack), then local avoidance might well be good enough. You may not take the "shortest' path, but you will reach the desired location nonetheless.

 

And if the ship navigates between solar system thru jump gates (or any clever sci-fi excuse for faster than light travel), then you can build a graph of jump point, and have your ship pathfind them for global navigation (using Navigation for instance).

 

Finally, if you have "death star attacks" sections, then you can build probably build a graph to navigate through the corridors. A little bit of extra work, I agree, but doable.

 

Oh, and to alleviate of your local avoidance raycast system, you might want to have a look at boids or any local steering system...

 

http://www.red3d.com/cwr/boids/

http://gamedevelopment.tutsplus.com/tutorials/understanding-steering-behaviors-collision-avoidance--...

 

Hope this helps 🙂

 

 

 

 

Message 6 of 6

Great info, thanks Mus!
______________________________________
Dan Matlack
Senior Content Manager || Games Solutions
Autodesk, Inc.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report