Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

I don't understand exactly how axis mapping works...

I've been reading a tutorial from the officials documentation on how to make a first person shooter character. And I stumbled upon axis mapping and mouse camera rotation.

With no explanation on how it works i've been given this code:

 InputComponent->BindAxis("LookX", this, &AFPSCharacter::AddControllerYawInput);
  InputComponent->BindAxis("LookY", this, &AFPSCharacter::AddControllerPitchInput);

LookX and LookY are the binding I made in the compiler , LookX has a Mouse X component with Scale 1.0 and LookY has a Mouse Y component with scale -1.0

I don't understand what scalling is doing and how AddControllerYawInput works. Can anyone explain in detail?

Product Version: UE 4.13
more ▼

asked Sep 06 '16 at 11:38 AM in C++ Programming

avatar image

1 1 1 3

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

see https://docs.unrealengine.com/latest/INT/Gameplay/Input/index.html.

Short summary: ActionMappings are a single keypress that is either pressed or not-pressed.

Axismappings have more granularity. Lets say you move your mouse to the left. It wouldnt help to just have an actionmapping, because then you would only know that the mouse is moved on one Axis, but you also want to know how fast it moves. This is where AxisMappings are handy. For example, if you move your mouse left fast, the AxisMapping will return -1, if you move your mouse left slow it will return something like -0.31, if you move it right slowly it will be 0.4 etc. A value of 0 will mean that it is not moved at all.

You can do similar for normal keys, lets use "A" and "D" as an example. You could do actionmappings for each key now, but that is not really great, since you have multiple nodes now. So you can define an AxisMapping named "MoveLeft". Add the "A" key and give it a scale of "1.0". This means that if you press "A", the Axismapping will trigger with a value of "1.0". Now add the "D" key with scale of "-1.0". If you press D now, it will return "-1.0".

You could also set the scale value to something higher. Like, set it to 5 instead of 1. Then the original value (i.e. 0.3) will be multiplied by 5 (this would give 1.5 for this example then).

The other difference is, that AxisMappings will trigger continuously each frame as long as the button is pressed. With an ActionMapping you will only get the initial press and then the release event.

The AddControllerYawInput does nothing else than telling the PlayerController to rotate his Yaw-Axis by the given Input value. The input value is usually expected to be between -1 and +1. So you can feed the output of a AxisMapping directly into the AddControllerYawInput node/function and it will rotate accordingly. Please note that for this to work, you need to have the setting "Use Controller Yaw" in the PlayerCharacter set to true (this is done by default in the engine).

Hope that helped a bit and did not confuse you even more :)

more ▼

answered Sep 06 '16 at 08:16 PM

avatar image

830 26 15 41

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question