Page 1 of 2

Car aligns to cardinal directions

Posted: Sun Aug 30, 2015 10:58 pm
by MalcolmCooks
Playing with RSO mod I drive my car a lot before I have built railways, and with the new stone brick/concrete roads you can build in .12, the car is becoming more useful... but it's still very frustrating to drive! You usually want to drive in a straight line but keep having to correct the direction of your car. It reminds me of the original Grand Theft Auto game, which had very similar controls for driving. In this game you can direct your car any direction, but the roads only go north/east/south/west. BUT if your car is very close to driving in one of those cardinal directions then after a short while it automatically would align itself to the road so that you don't have to keep correcting your steering or crash into things. Could the same thing be implemented in Factorio? I think even though it's a little thing it would ivprove the driving controls a lot :mrgreen:

Re: Car aligns to cardinal directions

Posted: Sun Aug 30, 2015 11:09 pm
by ssilk
Yeah. As long as it takes, use this mod: Better vehicle control https://forums.factorio.com/forum/vie ... =87&t=8976

(Which reminds me to go through all 0.11 mods, that are meanwhile converted :) )

Re: Car aligns to cardinal directions

Posted: Sun Aug 30, 2015 11:14 pm
by MalcolmCooks
ssilk wrote:Yeah. As long as it takes, use this mod: Better vehicle control https://forums.factorio.com/forum/vie ... =87&t=8976

(Which reminds me to go through all 0.11 mods, that are meanwhile converted :) )
Oh thanks for showing me this!

Re: Car aligns to cardinal directions

Posted: Mon Aug 31, 2015 2:00 pm
by orzelek
It would be nice to have it in base game.
Using mod for this is a bit.. clunky.
Auto align of driving direction if it's near one of cardinals would be neat. (using 4/8/16 cardinals).

Re: Car aligns to cardinal directions

Posted: Mon Aug 31, 2015 5:09 pm
by lancar
As I previously suggested this, I wholeheartedly support it.
Driving in a tightly built factory is a complete pain.

Re: Car aligns to cardinal directions

Posted: Wed Sep 02, 2015 9:23 pm
by MalcolmCooks
Yeah, even if a mod exists to fix it, I still think this should be something in the base game. But in the meantime, I don't mind using a mod for it

sticky car steering

Posted: Tue May 15, 2018 5:21 pm
by mnicolella
When steering the car, can the direction be made a little sticky so that it's easier to go exactly north/south/east/west?

Re: sticky car steering

Posted: Tue May 15, 2018 5:54 pm
by steinio

Re: sticky car steering

Posted: Wed May 16, 2018 12:08 pm
by Tekky
I like the idea.

However, in the options menu, the player should be able to configure how close you must be to one of the cardinal directions for it to snap. By setting this value to 0, it would be possible to deactivate this feature altogether.

Please restrict vehicle moving angles some way

Posted: Tue Oct 30, 2018 5:55 pm
by Zaflis
I'm author of mod Vehiclesnap, but i too have moments when i want to play just "pure vanilla" - no. mods. at. all. Let me show what i mean first:
https://www.youtube.com/watch?v=9X-4AqpFhUE

The controls are very touchy and it's almost impossible to drive straight along tracks, and that's even if the car sprite is pointing exactly downwards. There's always this little bit of sway to the side caused by angle being not for example 180 degrees but 178 or something. Closest sprite you can render is same as 180's, but game does no attempt to interpolate it to closest matching sprite angle over time (or any other form of "snapping").

What i did with mod is just that, 16 possible angles that car can drive to but i don't expect vanilla to work like that. It would likely be enough if just sprite angles were possible. And doing it in LUA is more performance expensive anyway than done internally. It's just a dirty hack. I even had to deal with issue where if i collided with water tile some not-yet-snapped diagonal angle, it would get stuck. The LUA code was trying to turn the car but it caused collision the moment car tried to move and hence causing it to stop. It was possible to remove the car with pickaxe and place it back down elsewhere. And because I solved that bug by only snapping in faster speeds, i couldn't allow it to snap when driving in reverse. That's because the speed when reversing with tank is so slow it is below the safe threshold.

So this really is a case that can't be left with modders hands. We don't have the means to do this properly, and your code would be faster and more failsafe.

Re: Please restrict vehicle moving angles some way

Posted: Thu Nov 01, 2018 7:25 pm
by Oktokolo
Locking vehicle orientation to multiples of 360°/n (with n configurable to the player's taste) would indeed be a nice QoL improvement in vanilla.

Re: Please restrict vehicle moving angles some way

Posted: Thu Nov 01, 2018 8:36 pm
by Tekky
This has already been suggested half a year ago in the following thread:

viewtopic.php?f=6&t=60395 sticky car steering

EDIT: Now that the threads have been merged, the link above is no longer valid.

Re: sticky car steering

Posted: Fri Nov 02, 2018 9:22 am
by Koub
[Koub] Merged into older topic with same or similar suggestion
There are also quite a number of requests for either :
- mouse control over direction
- following automatically the roads/stone paths

Re: sticky car steering

Posted: Sat Nov 03, 2018 12:44 am
by Oktokolo
Koub wrote:
Fri Nov 02, 2018 9:22 am
There are also quite a number of requests for either :
- mouse control over direction
- following automatically the roads/stone paths
Obviously, just snapping to angles is the easiest-to-implement of that requests (and VehicleSnap already implements it).

Re: sticky car steering

Posted: Sat Nov 03, 2018 7:41 pm
by Zaflis
Oktokolo wrote:
Sat Nov 03, 2018 12:44 am
Obviously, just snapping to angles is the easiest-to-implement of that requests (and VehicleSnap already implements it).
But as i said, it's not implementing it "properly". I had to use the onTick event, so it's actually doing something 60 times a second even if just waiting for delay or someone to step in a vehicle. Checking events now, I should at least use
https://lua-api.factorio.com/latest/eve ... nged_state

And don't you ever want to play vanilla game, or join multiplayer with others? You can't demand everyone to play with mods, so you face the issue occasionally anyway. Actually with mods you face the issue even less because you don't need cars after your first airplane.

Re: sticky car steering

Posted: Sat Nov 03, 2018 8:10 pm
by Oktokolo
Zaflis wrote:
Sat Nov 03, 2018 7:41 pm
Oktokolo wrote:
Sat Nov 03, 2018 12:44 am
Obviously, just snapping to angles is the easiest-to-implement of that requests (and VehicleSnap already implements it).
But as i said, it's not implementing it "properly".
Koub mentioned related requests, of wich i think, that they are not as easy to implement in vanilla, as vehicle snapping.
I am pro adding vehicle snap to vanilla and if they do it, they will do it right.
I mentioned VehicleSnap as prior art they could look at to see, how the feature could work from a user's point of view.

That said, obviously, checking vehicle orientation six times per second should be enough - you definitely do not have to do it each tick. And enabling the check only for vehicles actually occupied by a player, is a good thing too.
But the orientation of an entity (like a vehicle) seems to just be a float. Doing orientation = (floor(orientation / step) * step) should not be costly enough to have an effect on UPS even when doing it every tick for a hundred cars on a really crowded map.

Re: Car aligns to cardinal directions

Posted: Sat Nov 17, 2018 7:59 pm
by Zaflis
Ok now i don't mind if they implement it or not anymore. I spent all day updating VehicleSnap and i highly doubt there is too much left it can be improved on. I went as far as using the vehiclestate events and turn off onTick when it's not needed. With the backwards driving and per-player options it is in a very good shape.

How i avoided the getting stuck in slow speed bug then? The mod is tracking something like tiles travelled per second, not exactly but in idea. 1 tile is very short distance, so i just had to find low enough time frame that it has to travel at least 2 tiles to keep snapping on, else it drops to regular driving mode. Even that is using ingame's events for tile change, so i'm doing next to nothing in terms of calculation.

Re: Car aligns to cardinal directions

Posted: Fri Feb 22, 2019 11:17 am
by MoleOnDope
Since there's still a lot of experimenting left to be done in vanilla for me personally, I haven't used mods yet, so no "vehicle snap" for me. It does sound interresting with driving in the cardinal directions is frequently needed but pretty much impossible as of right now. However, I'm not sure if this might not annoy me sometimes, depending on the situation.
As an alternative, I found another suggestion here:

viewtopic.php?f=6&t=64257

It proposes the possibility to rotate a still standing vehicle to the four cardinal directions (beginning with the closest one) with the 'r'-Button, without the whole process of picking it up an replacing it.
I love this solution because it won't mess with the steering when you don't expect/need it to.
And moreover, it's 1000% more intuitive than giving the user another slider in another submenu to define a custom threshold, which would make sense... But also be kinda ugly :?

Re: Car aligns to cardinal directions

Posted: Fri Feb 22, 2019 11:57 am
by bobucles
You can vehicle snap in vanilla by picking up the car and plopping it down in one of 4 directions. It's not perfect but it can be handy.

Re: Car aligns to cardinal directions

Posted: Sat Feb 23, 2019 10:17 pm
by MoleOnDope
bobucles wrote:
Fri Feb 22, 2019 11:57 am
You can vehicle snap in vanilla by picking up the car and plopping it down in one of 4 directions. It's not perfect but it can be handy.
And in the linked post I explain a bit more in-depth why I dislike this kind of unnecessary workaround :D
But thanks for the tip anyway!