How would you implement an auto-walk function?

Discuss modding questions and implementation details.
jedidia
Posts: 201
Joined: Sat Sep 15, 2018 9:49 am

How would you implement an auto-walk function?

Post by jedidia »

So, I'm fooling around a bit with daggerfall unity and trying out some stuff. One of the things I wanted to do was an "auto-walk" functionality, that is, that the player keeps walking even though no key is pressed.

I guess I could just do it via the player objects position component, but that would involve some messy math and probably skip some essential code, like for example stamina consumption.
So what I tried instead was to programmatically inject a MoveForward action to the InputManager every frame. But it seems that doesn't do anything.

So, any ideas how this could be implemented via modding?

jedidia
Posts: 201
Joined: Sat Sep 15, 2018 9:49 am

Re: How would you implement an auto-walk function?

Post by jedidia »

Ah well, figured out that adding any actions to InputManager has no efffect whatsoever because it clears current actions *before* processing them, so although there are public functions for adding actions, they are ignored (respectively only get registered as completed actions). I'm not sure if that design is intended or not. Processing actions first and processing input afterwards would delay reaction time by one frame, but in my experience that's not an issue, and it would be much more modder friendly. There might be other side effects that I'm not currently seeing, however.

I did achieve my goal by invoking ApplyHorizontalForce directly through the dark magic of reflection. That too, of course, might have quite a few unintended consequences. Time will tell....

User avatar
Interkarma
Posts: 7234
Joined: Sun Mar 22, 2015 1:51 am

Re: How would you implement an auto-walk function?

Post by Interkarma »

Welcome to the forums jedidia. :)

I think auto-walk is one of those things that's better off in the core than a mod. It would be much easier to weave into the input flow without having to work from the outside back in.

I've had a few requests for this in the past, and it's something I'd like to add. The main thing stopping me right now is there's no free spot on the binding interface for this. We could have the binding in InputManager, but then player might bind a conflicting key and it wouldn't be clear to them what went wrong.

One option is to repurpose one of the less used binds. "Notebook" comes to mind as this does nothing even in classic. It's just a wasted binding slot right now.
binding-interface.jpg
binding-interface.jpg (128.14 KiB) Viewed 2654 times
Something else I've been considering is repurposing the "Joystick" button into a "More" button, or similar. Then use a custom UI (a scrolling list like save/load interface) to present unlimited custom binds that don't exist in classic. This would also need adequate feedback to ensure player could identify binding conflicts though.

Al-Khwarizmi
Posts: 177
Joined: Sun Mar 22, 2015 9:52 am

Re: How would you implement an auto-walk function?

Post by Al-Khwarizmi »

Actually I would like to see the intended notebook implemented at some point in the future (even if it's not core but mod, as it never made it to classic), so I vote for turning "Joystick" into "More", which also looks more flexible for future bindings (and mod bindings?)

Also, the buttons (joystick, mouse, etc.) have some extra space at the sides so maybe they could be shortened a bit to make room for "More" without removing "Joystick"?

User avatar
Hazelnut
Posts: 3014
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: How would you implement an auto-walk function?

Post by Hazelnut »

Alternatively we could bypass the need for more keybinding and have double tap forward activate it or something like that. Depends whether theres a bunch of other new keys needed, as these kinds of mechanics are often clumsy.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

jedidia
Posts: 201
Joined: Sat Sep 15, 2018 9:49 am

Re: How would you implement an auto-walk function?

Post by jedidia »

I think auto-walk is one of those things that's better off in the core than a mod.
Undoubtedly, but for the mod I have in mind I need to have it trigerable by code, not just by key binding.
have double tap forward activate it or something like that.
I think that specific suggestion could get rather annoying in combat... ;)
Actually I would like to see the intended notebook implemented at some point in the future (even if it's not core but mod, as it never made it to classic),
I second that very strongly. It's a pitty almost no RPGs provide editable in-game journals...
Speaking about which, can a mod actually save data to the save game? Is there a serialisation callback or something?

User avatar
Jay_H
Posts: 4059
Joined: Tue Aug 25, 2015 1:54 am
Contact:

Re: How would you implement an auto-walk function?

Post by Jay_H »

EDIT: I see the poster's point, so I deleted this.
Last edited by Jay_H on Mon Sep 17, 2018 7:02 pm, edited 1 time in total.

User avatar
TheLacus
Posts: 1305
Joined: Wed Sep 14, 2016 6:22 pm

Re: How would you implement an auto-walk function?

Post by TheLacus »

jedidia wrote: Sun Sep 16, 2018 6:27 pm
Actually I would like to see the intended notebook implemented at some point in the future (even if it's not core but mod, as it never made it to classic),
I second that very strongly. It's a pitty almost no RPGs provide editable in-game journals...
Speaking about which, can a mod actually save data to the save game? Is there a serialisation callback or something?
It is not yet publicly documented (it will be soon) but you can use IHasModSaveData interface to store an instance of a custom class in a save.

jedidia
Posts: 201
Joined: Sat Sep 15, 2018 9:49 am

Re: How would you implement an auto-walk function?

Post by jedidia »

Nice! Don't need it right now, but good to know.

For now, I seem to be having a bit of a different problem. I just tried my mod outside of the unity editor (i.e. in a regular game installation) for the first time, and it does... nothing. Can I enable log output somewhere? I'm not seeing anything in the settings, and the last log in the data folder is like a week old, nothing new gets written...

User avatar
TheLacus
Posts: 1305
Joined: Wed Sep 14, 2016 6:22 pm

Re: How would you implement an auto-walk function?

Post by TheLacus »

The main log is output_log.txt (here location for all platforms) and this is also where any information for mods will be shown. It is overwritten every time you launch the game. Let me know if you need more assistance :)

EDIT
Save interface is now documented here.

Post Reply