Page 1 of 3

How would you implement an auto-walk function?

Posted: Sat Sep 15, 2018 9:56 am
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?

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

Posted: Sat Sep 15, 2018 10:10 pm
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....

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

Posted: Sat Sep 15, 2018 11:00 pm
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 2664 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.

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

Posted: Sun Sep 16, 2018 8:43 am
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"?

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

Posted: Sun Sep 16, 2018 9:22 am
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.

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

Posted: Sun Sep 16, 2018 6:27 pm
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?

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

Posted: Mon Sep 17, 2018 2:06 pm
by Jay_H
EDIT: I see the poster's point, so I deleted this.

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

Posted: Mon Sep 17, 2018 4:54 pm
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.

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

Posted: Mon Sep 17, 2018 9:54 pm
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...

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

Posted: Mon Sep 17, 2018 11:42 pm
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.