Tuesday 15 January 2013

c# - What parameters can I use with Unity Input.getAxis? -



c# - What parameters can I use with Unity Input.getAxis? -

unity .getaxis(string name) seems homecoming thought offset generated user input (arrows, mouse or joystick). homecoming values conveniently in interval of <-1; 1> except mousewheel.

from various code samples can see many ways of getting input, there seems no actual name/input list. in case, want enable zoom using wheel or pgup , pgdn. wheel code looks this:

movement.y -= resourcemanager.scrollspeed * input.getaxis("mouse scrollwheel");

but page downwards , page up? and, in general, how can know names utilize in method?

input.getaxis , input.getbutton (as getbuttondown , getbuttonup) homecoming state of 1 of virtual input axis defined in input manager.

the homecoming values doesn't need in range [-1, 1]. virtual axes represent absolute value represented value between -1 , 1. there axes homecoming relative motion the predefined "mousewheel", "mouse x" , "mouse y". homecoming amount axis has moved since lastly frame.

the mousewheel has additional "problems". delta value taken os. if user has set scroll wheel advance 3 lines per "scroll unit", values of multiple of 3. if manage spin wheel fast plenty might values greater 3 or smaller -3.

there no default axes pageup or pagedown, can add together them if like. careful, getaxis homecoming state of virtual axis. when hold downwards positive button "1" long hold button down. if want hear events have utilize getbuttondown / getbuttonup.

however if want check key it's simpler utilize getkeydown / getkeyup takes keycode.

something like:

if(input.getkeydown(keycode.pageup)) movement.y -= 1; if(input.getkeydown(keycode.pagedown)) movement.y += 1;

edit if want know commonly available key names, take @ conventional game input page. @ bottom there's list of mutual keynames including "page up" , "page down". input manager refuses wrong key names. if type 1 in, unfocus input field , value stays, it's correct.

if set positive button whenever press button downwards virtual axis "slowly" increment 0 1 depending on "sensitivity" setting. sensitivity acceleration factor. if release button homecoming "slowly" 0 depending on "gravity" value deceleration factor.

if setup positive , negative button, axis can go both ways 1 when positive button pressed , downwards -1 when press negative button. if "snap" true snap 0 if press opposite button instead of going 0 , start growing in opposite direction.

the "dead" value defines dead-zone. if value of axis smaller dead (or greatern -dead) treated 0. of import real analog input devices have jitter around resting position.

the remaining properties "invert", "type" , 1 should clear when reading documentation.

it's possible define 2 axis same name defaule "horizontal" , "vertical" axes. axes same name treated one.

i think should cover of input manager stuff.

c# unity3d

No comments:

Post a Comment