Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Demo Scene - Snake - Navmesh
#1
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
Reply
#2
(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,
Reply
#3
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
Reply
#4
(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,
Reply