A* Pathfinding Project

Top down 2d, AI Path with rotation off


#1

Trivial top down 2D game using AI Path with rotation off. Following various posts on forum, it suggests set “Rotation speed” to zero, then disable “Slow When Not Facing Target” flag. However the character doesn’t move until I enable “Rotation In 2D” flag. It’s weird, since my purpose is to disable rotation in 2D…

And considering rotation off + top down 2D is very trivial setup, maybe it’s worth to add a 2d rotation off mode for AI Path.

v4.1.16


#2

Hm… There definitely seems to be something going on here. There was another user with a similar problem a few days ago, but I couldn’t replicate it. For me that setup works perfectly fine.

Can you replicate it in the “RVO 2D” example scene?


#3

Yes in Example16_RVO 2D.

  • Delete all AI except AI (1)
  • Set Rotation Speed to 0
  • Disable Slow When Not Facing Target
  • Disable Rotation In 2D

Play game, nothing happens. Enable Rotation In 2D, AI starts moving.

v4.1.16, Unity 2.17.4.1f1


#4

Wait… Disable rotation in 2D?
If you are making an agent for a top down 2D game then you definitely should have rotation in 2D enabled. Why do you want to disable it?


#5

See the unity 2d example screenshot, it’s old school top-down, but the character won’t rotate.


#6

Yes, but if you set the rotation speed to zero, then the character will not rotate anyway (I think)


#7

Yes, it works with the combination of rotationSpeed=0,showWhenNotFacingTarget=false,rotationIn2D=true. It just the naming of “Rotation In 2D” confusing me, maybe just bad naming.


#8

Yeah, perhaps it is. I think I’m going to change that so that you get a dropdown for “rotation mode” with the options “disabled”, “z axis forward” and “y axis forward”. Does that seem more intuitive for you? Or do you have any other suggestions that are more intuitive?


#9

Sounds good already, or maybe rotationMode=disable/2d/3d are more intuitive for beginners. Your call.


#10


#11

Actually. Nevermind. That setup does not work. The AIPath script needs to know the forward axis even when rotation is disabled. This works better:



#12

This setup is PRO version only, right?


#13

No, this should work just as well in the free version.

The released version does not contain the above inspector layout however, but you can download the latest beta which does include it: https://www.arongranberg.com/astar/download.