Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing keyboard up/down/left/right buttons to w/s/a/d in Spectator Mode #253

Closed
mansimov opened this issue Sep 25, 2017 · 5 comments
Closed
Labels

Comments

@mansimov
Copy link

Hi,

First of all thanks for the great framework.

I am wondering whether it is possible to change the assignment of keys up/down/left/right to w/s/a/d in spectator mode ? Thanks.

@Miffyli
Copy link
Collaborator

Miffyli commented Sep 25, 2017

I think you can do this by simply changing the settings when you launch a vizdoom game, and the changes will persist (haven't checked).

You can also add game arguments to bind the buttons you want. If game is a DoomGame instance in Python, then this will map u/d/l/r to WASD:
game.add_game_args('+"bind w +forward" +"bind s +back" +"bind a +left" +"bind d +right"')
Do note that these changes may persist between vizdoom launchers. E.g. if you unbind keys, you have to rebind them again to use them later.

@mansimov
Copy link
Author

Hi @Miffyli
Thanks for your quick reply.

I have tried to add that line to spectator.py https://github.com/mwydmuch/ViZDoom/blob/a3367d9dd59b47493a14606e19752e9ade639ba0/examples/python/spectator.py instead of line 36 and it didn't work.

Any suggestions on how I can debug it ? I am using latest vizdoom with anaconda3

@Miffyli
Copy link
Collaborator

Miffyli commented Sep 25, 2017

Hmm with that setup it works for me (Windows 10, Python 3.5, VizDoom 1.1.0). I don't think change in version should have an effect here as this is zdoom level stuff.

Here are the lines 33-44 I used just in case. Other than that I do not know what to say to debug this :(

# Enables freelook in engine
game.add_game_args('+"bind w +forward" +"bind s +back" +"bind a +left" +"bind d +right"')

game.set_screen_resolution(ScreenResolution.RES_640X480)

# Enables spectator mode, so you can play. Sounds strange but it is the agent who is supposed to watch not you.
game.set_window_visible(True)
game.set_mode(Mode.SPECTATOR)

game.init()

@mwydmuch
Copy link
Member

Hello @emansim,
when you launch an instance of vizdoom, it will create _vizdoom.ini in your working directory (if it doesn't exist yet). This file contains all the additional engine settings, including key bindings, you can edit it freely.

You can save it in some better location and load using this function:
https://github.com/mwydmuch/ViZDoom/blob/master/doc/DoomGame.md#setDoomConfigPath

@mansimov
Copy link
Author

mansimov commented Sep 27, 2017

@mwydmuch

I modified _vizdoom.ini and it worked for me ! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants