Obi Official Forum
Demo Scene - Snake - Navmesh - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Demo Scene - Snake - Navmesh (/thread-4336.html)



Demo Scene - Snake - Navmesh - devmert - 20-08-2024

Hello,

The controls of the snake in your Snake demo are good but I want to move it only on the ground using the point&click logic mechanics using the navmesh agent.

How can I do it?
Thanks


RE: Demo Scene - Snake - Navmesh - josemendez - 20-08-2024

(20-08-2024, 08:27 PM)devmert Wrote: Hello,

The controls of the snake in your Snake demo are good but I want to move it only on the ground using the point&click logic mechanics using the navmesh agent.

How can I do it?
Thanks

Hi there!

Can’t really help you with navmesh stuff, as this forum is for questions related to Obi.
For the point and click logic I would start by looking at Unity’s raycast method, and for questions related to how to use the navmesh system I would suggest asking on Unity discussions.

Once you have your point+click+navmesh system working, it’s just a matter of moving the snake’s head towards the destination point.

Kind regards,


RE: Demo Scene - Snake - Navmesh - devmert - 20-08-2024

My English is not very good, I guess I explained it wrong. I know how to use Navmesh, what I meant was

We can control the snake in snake demo scene with keyboard. You have a snake controller script.

I want to learn this. How can I make changes to the script so that this snake goes where I click in the scene. Where should I start? It's a very general question, but I could use some advice. Thanks


RE: Demo Scene - Snake - Navmesh - josemendez - 21-08-2024

(20-08-2024, 10:47 PM)devmert Wrote: My English is not very good, I guess I explained it wrong. I know how to use Navmesh, what I meant was

We can control the snake in snake demo scene with keyboard. You have a snake controller script.

I want to learn this. How can I make changes to the script so that this snake goes where I click in the scene. Where should I start? It's a very general question, but I could use some advice. Thanks

Hi,

Assuming you already have the position in space you want the snake to move towards, the key is realizing what do the existing input controls allow the snake to do:

- You can point the head of the snake using WASD.
- You can make the snake move in the direction that the head is pointing by pressing J.

So all you have to do is point the head (which is a regular transform) towards the target position using vector math instead of keyboard input, then make the snake advance until the head is sufficiently close to it. If you have trouble with the math, I'd suggest starting there. Some resources:

https://docs.unity3d.com/Manual/VectorCookbook.html
https://learn.unity.com/tutorial/vector-maths

kind regards,