July 31, 2017 at 19:43 #21573
I am attempting to make a mobile game w/ a Joystick (However, WASD Keys should have the same problem as well).
The issue is that whenever I Move with a joystick, I have to give the MoveTo(destination, append) a destination so it know “where” to move. Normally thats fine. I figured it wouldn’t be a big problem to get a joystick direction. and feed it to ApexPath as currentDestination + Vector3.Forward.
My issue however, has to do with the Y Axis.
Most Joystick tutorials that I find deal with a flat surface (X, 0, Z), completely ignoring hills, or any sort of fluctuation on the Y. But Apex can grid on the Y, and I need the Character to know its against a Hill going up, or down, get that value, and feed it to MoveTo.
My Question is:
Is there a pre-made configuration in Apex Path (or Tutorial, or reference somewhere) that deals with mobile joystick, or WASD Key Movements? (either of the two should work).August 1, 2017 at 11:14 #21578
Thanks for your post.
While we do not provide any tutorials in regards to different movement schemes per se, the answer to your question should be simple.
Basically, if I understand you correctly, you want to give MoveTo the right Y-value depending on the height map as generated by the grid. This can be done simply by sampling the grid’s height at the given location.
For the most part however, Apex path will sample the height automatically when needed, so all you really need to do is ensure that the position you give to MoveTo is within a valid grid’s bounds.August 1, 2017 at 19:55 #21599
Hi thank you for the response.
I think I found what I needed in your Asset Store Package (Apex Survival Shooter Tutorial).
Typically, in most of your examples, you get a Vector3 point, and feed that point to MoveTo. however, my problem was that I didnt know how to get a Vector3 point that APEX would consider legitimate while using WASD or a Joystick.
I notice in your Survival Shooter, you Sample the grid area around a unit, to give the Unit a list of possible locations to moveTo.
The second problem to this (which i still need to do performance testing on) is that i need to constantly feed Vector3 points to MoveTo (as I am holding down the “W” key for forward, or moving the joystick forward), whereas in point-and-click model, you just simply feed a point once, everytime the left mouse button is released.
The sampling in ScanForPositions.cs ( I think ) will work for me, and seems reliable.
It seems ill have to run this everytime a WASD key is pressed to sample the area around me, and feed it to MoveTo, based on the keyPress.August 2, 2017 at 09:51 #21610
Admitted, traditional A* pathfinding is typically not the best choice for WASD- or joystick-based movement, for the reasons that you list yourself.
However, on the plus side, Apex Path is very fast at finding paths that are very short.
In the Survival Shooter demo, position sampling is done at an interval that is much slower than the frame rate (e.g. 3-4 times per second). This way, you don’t sample on every single key press.August 2, 2017 at 17:28 #21617
Do you have any recommendations for approaching this?
At the moment I am thinking of making my own version of the sampling code, and trying to control the “feed time” to MoveTo.
It’s not an approach I like, so I’m open to suggestions.August 2, 2017 at 18:31 #21619
Honestly, I wouldn’t use pathfinding for that type of movement. It would probably make more sense to go with a steering-based approach: just move the character, but do some raycasts/spherecasts or sweeps in the movement direction, if anything is hit, prohibit moving, otherwise allow movement.
If you have AI characters in your game, they are a perfect match for pathfinding.
If you decide that you still want to use pathfinding, the only advice I can provide is: keep the grid as small and simple as possible, keep path requests as short as possible, request paths as rarely as possible. Obviously you will need to find the right balance between responsiveness and performance, no easy task I think.
You must be logged in to reply to this topic.