x

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"

Head Mount Display Camera Turn (with Keyboard)

Hey guys,

i wanted to implement a way to turn my Camera with the keys Q and E (+30 and -30 degrees).

alt text

I have 2 Problems. If i use the Blueprint without the -1 float component, the Camera turn 30 degrees (in the opposite direction) with the first Keypress and with the second Keypress it turns back to it's previous position. Because the set Base Orientation and Rotation Offset subtracts the value it gets from the base value. 0 - (-30) = 30 (that's why the opposite direction), but somehow the next value, will be 0 again, thats why it gets the previous position after a second input.

That's why i added the -1 component. It works as long as the Head Mount Display Yaw is 0, if it's not 0, the value will differ from 30 degrees. For Example if my HMD Yaw is -60 Degrees and i press Q, the camera turn to +90 Degrees, because of the -1 component.

Can someone help with this? I am completly desperate about this and have no idea how to solve it.

Product Version: UE 4.7
Tags:
blueprint.png (76.7 kB)
more ▼

asked May 20 '15 at 02:46 PM in Blueprint Scripting

avatar image

Chaptrap
3 1 2 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Ok I found it and I wasn't aware of this too, it's kind of undocumented 0o

In the PlayerController source you find this call resulting in this

 void APlayerController::AddYawInput(float Val)
 {
     RotationInput.Yaw += !IsLookInputIgnored() ? Val * InputYawScale : 0.f;
 }

So the PlayerContoller has a value called InputYawScale that ist default set to 2.5 in the BaseGame.ini

So we can either set it by hand like I did it in the Screenshot or you can do it in the DefaultGame.ini in your project's config folder:

 [/Script/Engine.PlayerController]
 InputYawScale=1.0

alt text

capture2.png (87.2 kB)
more ▼

answered May 22 '15 at 01:46 PM

avatar image

MarcelBlanck
363 10 58 24

avatar image MarcelBlanck May 24 '15 at 03:21 AM

Did this help you Chaptrap?

avatar image Chaptrap May 24 '15 at 08:25 AM

First, i'm sorry for no reply. Haven't seen your solution. Second i'm a little busy at the moment and don't have my hands on the Oculus right now. I'll try this next week when i can work with the Oculus again. But thanks in advance, this looks promising :D

avatar image Chaptrap Jun 01 '15 at 10:21 AM

Okay, i finally was able to get my hands on the Oculus again. Your solution worked very well. This is exactly what i wanted, so thanks a lot!

avatar image MarcelBlanck Jun 01 '15 at 11:21 AM

I'm glad this helped you!

Would you like to accept the answer? You know, to indicate it for others and for my Karma Score =)

P.S. 8 Days without VR development? 8 hours ok, one has to sleep now and then, but 8 days... ;)

avatar image Chaptrap Jun 01 '15 at 01:28 PM

Well i was at home, during holidays (in germany) and i can't work with the oculus on my home computer :D

avatar image MarcelBlanck Jun 01 '15 at 02:25 PM

Hope you had a good time in Germany!

Argh I corrected a typo and then all the green was gone. I took that chance and extracted the comment as answer. Maybe you can accept again? I did not expect this to break the mechanism sorry.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Well I try to explain it in pseudo code with overexpressive variable names:

 NewYawDegree = CurrentYawDegree + 30;
 if (NewYaw >= 360.f)
 {
     NewYaw = NewYaw - 360.f;
 }
 CurrentYawDegree = NewYawDegree;

And for your tunr in the other direction:

 NewYawDegree = CurrentYawDegree - 30;
 if (NewYaw < 0.f)
 {
     NewYaw =  360.f + NewYaw; // NewYaw is negative here so minus is calculated
 }
 CurrentYawDegree = NewYawDegree;


Of course you can combine it like that:

 NewYawDegree = CurrentYawDegree + PositiveOrNegativeChangeValue;
 if (NewYaw >= 360.f)
 {
     NewYaw = NewYaw - 360.f;
 }
 else if (NewYaw < 0.f)
 {
     NewYaw =  360.f + NewYaw; // NewYaw is negative
 }
 CurrentYawDegree = NewYawDegree;

If PositiveOrNegativeChangeValue can be higher than 360 or lower than -360 normalization could be done in while loops. Shown here in a more condesed way:

 NewYawDegree = CurrentYawDegree + PositiveOrNegativeChangeValue;

 while (NewYaw >= 360.f) NewYaw = NewYaw - 360.f;
 while (NewYaw <= 360.f) NewYaw += 360.f;
 if (NewYaw < 0.f) NewYaw += 360.f;

 CurrentYawDegree = NewYawDegree;

Optionally you can also turn your Pawn, instead of recallibrate the HMD. Maybe that makes more sense if the pawn can move also.

more ▼

answered May 20 '15 at 03:20 PM

avatar image

MarcelBlanck
363 10 58 24

avatar image Chaptrap May 20 '15 at 07:25 PM

Thanks a lot, but is there a way to get this done with Blueprints?

avatar image MarcelBlanck May 21 '15 at 12:13 PM

You need the nodes +, -, <, >, =, branch (for the if), and WhileLoop. I have no time to solve it for you and make a screenshot, but it should be super easy or at least good practice if you really wanna work with UE4.

I just thought it might be even easier if you just use Add Controller Yaw Input and give it the value 30 or -30. Should do the job on a Pawn or Character.

Try to figure it out, this is where proficiency is comming from thumbs up

Good Luck!

avatar image Chaptrap May 22 '15 at 09:09 AM

I'm still having the Problem, that my values are extremly weird, eventhough i have 30 degree turns, my camera turns like 100 or 120 degrees per Key press.

alt text

blueprint.png (113.5 kB)
avatar image Narghile May 24 '15 at 04:06 AM

A little late now, but this is what I was using

alt text

Narg

capture.jpg (78.9 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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