Instant turn rate?

Instant turn rate?

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Rampoina
Posts: 12
Joined: 19 Oct 2018, 17:32

Instant turn rate?

Post by Rampoina » 19 Oct 2018, 18:44

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?
0 x

Kloot
Spring Developer
Posts: 1865
Joined: 08 Oct 2006, 16:58

Re: Instant turn rate?

Post by Kloot » 19 Oct 2018, 20:11

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.
0 x

Rampoina
Posts: 12
Joined: 19 Oct 2018, 17:32

Re: Instant turn rate?

Post by Rampoina » 19 Oct 2018, 20:53

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.
0 x

User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14599
Joined: 17 Nov 2005, 02:43

Re: Instant turn rate?

Post by Forboding Angel » 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
0 x

Rampoina
Posts: 12
Joined: 19 Oct 2018, 17:32

Re: Instant turn rate?

Post by Rampoina » 20 Oct 2018, 13:54

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.
0 x

Kloot
Spring Developer
Posts: 1865
Joined: 08 Oct 2006, 16:58

Re: Instant turn rate?

Post by Kloot » 20 Oct 2018, 16:10

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.
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.

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.
0 x

Rampoina
Posts: 12
Joined: 19 Oct 2018, 17:32

Re: Instant turn rate?

Post by Rampoina » 20 Oct 2018, 17:25

Kloot wrote:
20 Oct 2018, 16:10
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.
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.

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.
0 x

Rampoina
Posts: 12
Joined: 19 Oct 2018, 17:32

Re: Instant turn rate?

Post by Rampoina » 21 Oct 2018, 16:05

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:

Code: Select all

        
        if (modWantedDir.x != 0.0f || modWantedDir.z != 0.0f) {
		    ChangeHeading(GetHeadingFromVector(modWantedDir.x, modWantedDir.z));
        }
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?
Last edited by Rampoina on 21 Oct 2018, 17:18, edited 1 time in total.
0 x

Kloot
Spring Developer
Posts: 1865
Joined: 08 Oct 2006, 16:58

Re: Instant turn rate?

Post by Kloot » 21 Oct 2018, 17:07

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
Last edited by Kloot on 23 Oct 2018, 20:07, edited 1 time in total.
0 x

Rampoina
Posts: 12
Joined: 19 Oct 2018, 17:32

Re: Instant turn rate?

Post by Rampoina » 21 Oct 2018, 17:27

Kloot wrote:
21 Oct 2018, 17:07
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.
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.
0 x

Rampoina
Posts: 12
Joined: 19 Oct 2018, 17:32

Re: Instant turn rate?

Post by Rampoina » 26 Oct 2018, 12:47

Kloot wrote:
21 Oct 2018, 17:07
EDIT: done in build 822-gcf9c812 following good Hacktober spirit
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
0 x

Kloot
Spring Developer
Posts: 1865
Joined: 08 Oct 2006, 16:58

Re: Instant turn rate?

Post by Kloot » 26 Oct 2018, 13:48

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?
0 x

Rampoina
Posts: 12
Joined: 19 Oct 2018, 17:32

Re: Instant turn rate?

Post by Rampoina » 26 Oct 2018, 13:58

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,
0 x

Kloot
Spring Developer
Posts: 1865
Joined: 08 Oct 2006, 16:58

Re: Instant turn rate?

Post by Kloot » 26 Oct 2018, 14:17

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.
0 x

Rampoina
Posts: 12
Joined: 19 Oct 2018, 17:32

Re: Instant turn rate?

Post by Rampoina » 26 Oct 2018, 17:04

Kloot wrote:
26 Oct 2018, 14:17
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.

Oh, that's good to know :P
My intention was to avoid having to set a high acceleration to achieve the maximum velocity instantaneously.
0 x

User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14599
Joined: 17 Nov 2005, 02:43

Re: Instant turn rate?

Post by Forboding Angel » 26 Oct 2018, 21:08

Kloot wrote:
26 Oct 2018, 14:17
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.
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).
0 x

Kloot
Spring Developer
Posts: 1865
Joined: 08 Oct 2006, 16:58

Re: Instant turn rate?

Post by Kloot » 27 Oct 2018, 02:35

Engine, this applied to handling of ground units with maxVelocity >= 10 elmos/frame. Build 832-g320ff24 includes a patch.
1 x

User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14599
Joined: 17 Nov 2005, 02:43

Re: Instant turn rate?

Post by Forboding Angel » 27 Oct 2018, 08:57

Ahh ok thanks for that! <3
0 x

Rampoina
Posts: 12
Joined: 19 Oct 2018, 17:32

Re: Instant turn rate?

Post by Rampoina » 27 Oct 2018, 13:57

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
Spring is a project to create the best RTS engine ever (no joke).
:P

I appreciate the work you're doing kloot, again if you need anthing I'll be happy to help.
0 x

User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14599
Joined: 17 Nov 2005, 02:43

Re: Instant turn rate?

Post by Forboding Angel » 28 Oct 2018, 01:29

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 :-))!
0 x

Post Reply

Return to “Game Development”