Hi folks! Does anyone know of a way to implement vertical movement in an rts setting, i.e. Homeworld style unit movement?
I have successfully set up my RTS camera and 2D movement, but I’d like the ability to move selected units up/down in the vertical space.
Mmm… that could totally work. I’d like to try and avoid physics based thought as I use time dilation as an alternative to real-time with pause, and physics stuff causes issues with that.
Alternatively, I was thinking that I could intersect the level with a horizontal plane and calculate the plane normal at the mouse pointer, the use that to calculate movement in the z-axis. I guess I could do that by just using X-Y coords and doing the same calculation, in lieu of having an invisible intersecting plane.
I’m surprised nobody has cracked this one tbh, and RWTP. Seems like RTWP is in every tactical games these days.
You can have an imaginary surface to trace against at any angle and placed anywere. It’s a pretty common thing to do, indeed. Trace from the screen center towards the mouse, the trace will intersect the plane giving you the desired intersection. To visualise it:
Thanks @Everynone! I’ll give this a shot. One thing I am not clear on though is how to integrate this into the player controller, which contains all the camera movement logic and inputs?
There are caveats and special cases that need handling, ofc. The above is NOT a complete system. Like going over the horizon - running out of the horizontal plane to trace against:
You can’t hit the green mark using the horizontal tracing… You may want to switch to another far away vertical plane to trace against - that’s why those functions spit out booleans. Print them to see which one fails. And handle the fail in some way. What is supposed to happen if we select a nav point outside of the playing field?
Besides, the above is set to 25000uus - 250 meters. Wiggling the mouse like that may simply take the whole thing too far. Up it a bit, print values.
If you want to continue with this (duh, ofc, we’re just starting), do ensure you wrap you mind around what this script is doing. It’s a really versatile set of nodes with countless application. Draw more debug to figure out what is what.
Thanks so much for the help and feedback! I really appreciate it!
I’ll play around with debugging and see what’s going on.
In theory I could give my levels HUGE bounding boxes, and they could act as planes to trace against perhaps?
This mechanic is central to my game, as you need to be able to bounce in and out of fps mode to direct units in 3d space, so I’d love to crack this
I guess another aspect is that I am using pawns, not characters, since all my units are ships, not people, so they don’t need much of the functionality that the character class has. They’re using 6DOF movement instead.
You want to trace here - not 2.5m uus away. Essentially, if you run ouf of horizontal plane, you trace on the vertical. And revert it when you reach the horizontal again. Now you have box without having a box.
Ah right! Okay, that makes sense.
What’s super weird is that the blue trace doesn’t move at all when I move the mouse, but when I press the alt key, the green trace moves in both Horizontal and Vertical, like it’s confused.