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?
How would you implement an auto-walk function?
-
- Posts: 201
- Joined: Sat Sep 15, 2018 9:49 am
-
- Posts: 201
- Joined: Sat Sep 15, 2018 9:49 am
Re: How would you implement an auto-walk function?
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....
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....
- Interkarma
- Posts: 7247
- Joined: Sun Mar 22, 2015 1:51 am
Re: How would you implement an auto-walk function?
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.
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.
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.
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.
-
- Posts: 177
- Joined: Sun Mar 22, 2015 9:52 am
Re: How would you implement an auto-walk function?
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"?
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"?
- Hazelnut
- Posts: 3016
- Joined: Sat Aug 26, 2017 2:46 pm
- Contact:
Re: How would you implement an auto-walk function?
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
-
- Posts: 201
- Joined: Sat Sep 15, 2018 9:49 am
Re: How would you implement an auto-walk function?
Undoubtedly, but for the mod I have in mind I need to have it trigerable by code, not just by key binding.I think auto-walk is one of those things that's better off in the core than a mod.
I think that specific suggestion could get rather annoying in combat...have double tap forward activate it or something like that.
I second that very strongly. It's a pitty almost no RPGs provide editable in-game journals...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),
Speaking about which, can a mod actually save data to the save game? Is there a serialisation callback or something?
- Jay_H
- Posts: 4070
- Joined: Tue Aug 25, 2015 1:54 am
- Contact:
Re: How would you implement an auto-walk function?
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.
- TheLacus
- Posts: 1305
- Joined: Wed Sep 14, 2016 6:22 pm
Re: How would you implement an auto-walk function?
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 wrote: ↑Sun Sep 16, 2018 6:27 pmI second that very strongly. It's a pitty almost no RPGs provide editable in-game journals...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),
Speaking about which, can a mod actually save data to the save game? Is there a serialisation callback or something?
-
- Posts: 201
- Joined: Sat Sep 15, 2018 9:49 am
Re: How would you implement an auto-walk function?
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...
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...
- TheLacus
- Posts: 1305
- Joined: Wed Sep 14, 2016 6:22 pm
Re: How would you implement an auto-walk function?
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.
EDIT
Save interface is now documented here.