Instant turn rate?
Moderator: Moderators
Instant turn rate?
I tried to make a unit that turns instantly by setting a really high turnRate, but then it swerves like crazy when traveling in a straight path.
I basically used https://github.com/spring-archive/sprin ... algame.sdd and just changed the turnRate of a unit.
Am I doing something wrong? or is this a bug/limitation?
I basically used https://github.com/spring-archive/sprin ... algame.sdd and just changed the turnRate of a unit.
Am I doing something wrong? or is this a bug/limitation?
Re: Instant turn rate?
Swerving at high turnRate values happens because unit motion also incorporates rotational acceleration, which can be changed only by (synced) Lua gadget code. This post shows one way of doing so in response to the same issue.
Re: Instant turn rate?
Thank you, but it's not quite working for me, now it doesn't swerve but when it stops sometimes the orientation changes. Also when rapidly changing directions sometimes it lags and doesn't start moving immediately.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Instant turn rate?
You can observe how I have fixed this in EvoRTS. Long story short, a turnrate of 5000 will achieve what you want without the drunk driving after the turn.
Edit:
Assuming you have implemented the above suggestions. This gadget is one of my little hobby horses of where I put things that are fixes to various things that I disagree with how the engine works. Perhaps you'll find it useful.
https://github.com/EvolutionRTS/Evoluti ... tfixes.lua
Additionally, I do a SHITLOAD of overrides using POST, which you might also find helpful to some extent:
https://github.com/EvolutionRTS/Evoluti ... s_post.lua
Edit:
Assuming you have implemented the above suggestions. This gadget is one of my little hobby horses of where I put things that are fixes to various things that I disagree with how the engine works. Perhaps you'll find it useful.
https://github.com/EvolutionRTS/Evoluti ... tfixes.lua
Additionally, I do a SHITLOAD of overrides using POST, which you might also find helpful to some extent:
https://github.com/EvolutionRTS/Evoluti ... s_post.lua
Re: Instant turn rate?
Forboding Angel wrote: ↑20 Oct 2018, 05:45 You can observe how I have fixed this in EvoRTS. Long story short, a turnrate of 5000 will achieve what you want without the drunk driving after the turn.
Edit:
Assuming you have implemented the above suggestions. This gadget is one of my little hobby horses of where I put things that are fixes to various things that I disagree with how the engine works. Perhaps you'll find it useful.
https://github.com/EvolutionRTS/Evoluti ... tfixes.lua
Additionally, I do a SHITLOAD of overrides using POST, which you might also find helpful to some extent:
https://github.com/EvolutionRTS/Evoluti ... s_post.lua
Actually I did look at your repo to figure out where to put that snippet, thank you for making it available.
First of all 5000 is not enough for me, you can clearly see (and feel) the unit turning, and then the problem I mentioned is still there, although much less pronounced. When the unit stops the orientation changes a tiny bit, if you use a higher turn rate this exacerbates.
If guys you need it tell me and I'll make a fork with the changes so you can test it (although it's just changing the turn rate, adding the fix, and optionally giving the unit very high acceleration and break rate)
PD: Forboding Angel, I tried testing your game directly from git, but it complains about a few packages, I'll download it from your website and test how your units move.
EDIT: I've tested it, your units have the same problem, sometimes when stopping they slightly change orientation.
Re: Instant turn rate?
The tendency of units to flip their orientation during a stop should be reduced in build 816-g8d93daa of the 104.0 maintenance branch, which is downloadable from here. Testing this would be appreciated.Rampoina wrote:now it doesn't swerve but when it stops sometimes the orientation changes. Also when rapidly changing directions sometimes it lags and doesn't start moving immediately.
Note: the maximum *sensible* turn-rate you can set is 32767 which corresponds to ~180 degrees per frame (a unit always picks the shortest angle when turning), and instant turns require that turn-acceleration matches this value as in the snippet I linked to.
Re: Instant turn rate?
Kloot wrote: ↑20 Oct 2018, 16:10The tendency of units to flip their orientation during a stop should be reduced in build 816-g8d93daa of the 104.0 maintenance branch, which is downloadable from here. Testing this would be appreciated.Rampoina wrote:now it doesn't swerve but when it stops sometimes the orientation changes. Also when rapidly changing directions sometimes it lags and doesn't start moving immediately.
Note: the maximum *sensible* turn-rate you can set is 32767 which corresponds to ~180 degrees per frame (a unit always picks the shortest angle when turning), and instant turns require that turn-acceleration matches this value as in the snippet I linked to.
It doesn't seem to make much difference, I also compiled the latest version on git (that took a while) and it doesn't help either.
Craziness begins to happen when moving the unit next to hills too, it starts spinning uncontrollably and I even some times the unit gets launched to space.
It could be great if we could look into that.
Re: Instant turn rate?
Ok I found the cause of one of the issues.
In https://github.com/spring/spring/blob/d ... e.cpp#L586 sometimes when stopping it wants to change heading from 0 to 0
GetHeadingFromVectorF returns -HALFPI in that case which is not correct
https://github.com/spring/spring/blob/d ... th.inl#L60
This was happening already but of course such a drastic change of heading was never made because of the slow turnRate of the units
Something like this would get rid of the issue:
Now there's the other issue with pathing that makes it turn drasticly specially when pathing around hills, but I think this one will be harder to fix.
Should I make a PR?
In https://github.com/spring/spring/blob/d ... e.cpp#L586 sometimes when stopping it wants to change heading from 0 to 0
GetHeadingFromVectorF returns -HALFPI in that case which is not correct
https://github.com/spring/spring/blob/d ... th.inl#L60
This was happening already but of course such a drastic change of heading was never made because of the slow turnRate of the units
Something like this would get rid of the issue:
Code: Select all
if (modWantedDir.x != 0.0f || modWantedDir.z != 0.0f) {
ChangeHeading(GetHeadingFromVector(modWantedDir.x, modWantedDir.z));
}
Should I make a PR?
Last edited by Rampoina on 21 Oct 2018, 17:18, edited 1 time in total.
Re: Instant turn rate?
No need, modWantedDir can no longer equal <0,0> as of 817-gfa7aedc.
Fixing terrain interaction for high-turnrate units may take either a clever hack or a rewrite, so I hope you can tolerate it fttb.
EDIT: done in build 822-gcf9c812 following good Hacktober spirit
Fixing terrain interaction for high-turnrate units may take either a clever hack or a rewrite, so I hope you can tolerate it fttb.
EDIT: done in build 822-gcf9c812 following good Hacktober spirit
Last edited by Kloot on 23 Oct 2018, 20:07, edited 1 time in total.
Re: Instant turn rate?
Sure, if I can help with anything let me know.
EDIT:
This would be an important feature for me, so I'm willing to get my hands dirty but of course I don't have any experience with the Spring codebase so you can definitely do it faster and better.
Re: Instant turn rate?
Damn, I didn't see your EDIT sorry.
Thank you very much for your effort.
I've tested it but unfortunately it seems like there's still issues.
I'm testing it on the "Twin Lakes Park" map by moving the unit close to the hills, I've made a small video so you can reproduce it:
https://peertube.mastodon.host/videos/w ... 2492c964b1
Re: Instant turn rate?
Your unit appears to be overshooting some of its waypoints rather than getting upset by terrain, which could result from a particular high maxVelocity / low brakeRate combination. Would you mind pastebinning the unitdef file and/or making a new video after typing /cheat into the console followed by /debugpath and pressing F2?
Re: Instant turn rate?
Of course, here's the video:
https://peertube.mastodon.host/videos/w ... f86ce86a5f
I'll post the UnitDef later
I've been playing with high acceleration/velocity but even if I use low values it seems to bug out, for the first video it was like this:
Acceleration = 1,
BrakeRate = 1,
StartVelocity = 10.0,
MaxVelocity = 10.0,
https://peertube.mastodon.host/videos/w ... f86ce86a5f
I'll post the UnitDef later
I've been playing with high acceleration/velocity but even if I use low values it seems to bug out, for the first video it was like this:
Acceleration = 1,
BrakeRate = 1,
StartVelocity = 10.0,
MaxVelocity = 10.0,
Re: Instant turn rate?
Thank you, the (quite fixable) problem here is that waypoint consumption does not keep pace at maxVelocity=10 with a turn-radius of effectively zero.
Incidentally "startVelocity" is only used by certain weapon types, not units.
Incidentally "startVelocity" is only used by certain weapon types, not units.
Re: Instant turn rate?
Oh, that's good to know
My intention was to avoid having to set a high acceleration to achieve the maximum velocity instantaneously.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Instant turn rate?
Can you expoud upon this a bit? You said the issue is quite fixable, but where I'm a bit confused is if you meant quite fixable in the game or in the engine. I assumed the former, bit if it is indeed the game, I'm not sure what needs to be done to fix it.
After watching the video I had assumed brakerate was an issue as well.
That said I don't really have much in the way of unit movement issues (unless I'm missing some big picture element here), so I'm not sure how much of this is applicable. That said, rampoina is doing essentially the same sort of unit movement I am, so it's probably more relevant than I realize. Evo uses a high acceleration rate with a low brakerate (this is so that units are responsive, but drift to a stop, creating a nice aesthetic).
Re: Instant turn rate?
Engine, this applied to handling of ground units with maxVelocity >= 10 elmos/frame. Build 832-g320ff24 includes a patch.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Instant turn rate?
Ahh ok thanks for that! <3
Re: Instant turn rate?
Thank you very much kloot.
I'm testing it and it seems like it's happening less often.
I was able to catch this on video, I don't know it it's related but sometimes it happens while moving normally:
https://peertube.mastodon.host/videos/w ... a4c8604228
This time it wasn't as extreme, but I wasn't joking when I said that sometimes the unit got launched to the moon.
With these settings:
Acceleration = 10,
BrakeRate = 10,
FootprintX = 2,
FootprintZ = 2,
MaxSlope = 15,
StartVelocity = 10.0,
MaxVelocity = 10.0,
MaxWaterDepth = 20,
MovementClass = "Default2x2",
TurnRate = 32767,
TurnRadius = 250,
I'm using those acceleration and brakeRate values to have instant stops and starts.
Basically I'm trying to model a movement similar to the one in Starcraft 2, that means instant stops and starts, fast units and instant turn rate. A movement system that basically responds instantly to every click of the user.
To me a movement system like that is very important, it is very hard for me to play games like total annihilation or any game where the units are slow and take ages to turn because they feel unresponsive to me.
I realize I'm pushing the engine a bit, but I don't see any reason why it shouldn't allow for that, specially taking into account these hefty goals
I appreciate the work you're doing kloot, again if you need anthing I'll be happy to help.
I'm testing it and it seems like it's happening less often.
I was able to catch this on video, I don't know it it's related but sometimes it happens while moving normally:
https://peertube.mastodon.host/videos/w ... a4c8604228
This time it wasn't as extreme, but I wasn't joking when I said that sometimes the unit got launched to the moon.
With these settings:
Acceleration = 10,
BrakeRate = 10,
FootprintX = 2,
FootprintZ = 2,
MaxSlope = 15,
StartVelocity = 10.0,
MaxVelocity = 10.0,
MaxWaterDepth = 20,
MovementClass = "Default2x2",
TurnRate = 32767,
TurnRadius = 250,
I'm using those acceleration and brakeRate values to have instant stops and starts.
Basically I'm trying to model a movement similar to the one in Starcraft 2, that means instant stops and starts, fast units and instant turn rate. A movement system that basically responds instantly to every click of the user.
To me a movement system like that is very important, it is very hard for me to play games like total annihilation or any game where the units are slow and take ages to turn because they feel unresponsive to me.
I realize I'm pushing the engine a bit, but I don't see any reason why it shouldn't allow for that, specially taking into account these hefty goals
Spring is a project to create the best RTS engine ever (no joke).
I appreciate the work you're doing kloot, again if you need anthing I'll be happy to help.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Instant turn rate?
Sc2 style movement was what I was going for in Evo as well, fwiw. My current solution was the "happy medium" that I found. It would be great to have this more fine tuned. It's looking REALLY good so far (thank you kloot )!