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"

Rotate Camera Blueprint with players

I'm making a 1vs1 fighting game with a shared camera. I want to rotate the camera so the viewangle stays on the same side of the players when they rotate around, similar to this game: https://www.youtube.com/watch?v=G7WZf6Q_QR4 (gameplay starts at ~3:37).

I've tried getting the players rotation and setting the camera actors rotation, but it doesn't seem to rotate correctly. Any suggestions would be greatly appreciated!

have a awesome weekend!

Product Version: UE 4.17
more ▼

asked Nov 17 '17 at 03:05 PM in Blueprint Scripting

avatar image

283 9 19 24

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

1 answer: sort voted first

you need to get middle location between players, then make CameraLocation - MiddleLocation, normalize result and this will be direction vector. Now you can use one of MakeRot functions. For example MakeRotFromX and rotate camera with this rotator.

more ▼

answered Nov 17 '17 at 03:10 PM

avatar image

4.3k 82 20 104

avatar image Samuelb Nov 17 '17 at 03:18 PM

Thank you for the answer! I'll give it a try and report back. My vector math is abit rusty.

avatar image Samuelb Nov 17 '17 at 03:37 PM

Hey does this same method apply if my camera is an component of an actor? I'm getting some really weird results, maybe i'm not calculating the math correctly.




centerpoint.png (124.3 kB)
camdirection.png (56.7 kB)
setcamrot.png (65.3 kB)
avatar image redbox Nov 17 '17 at 04:15 PM

firsst of all make sure that your camera doesn't uses control rotation

avatar image Samuelb Nov 17 '17 at 04:17 PM

yeah its disabled for sure. In any case is the math on those screencaps correct?

avatar image redbox Nov 17 '17 at 04:42 PM

For me it looks ok.

avatar image redbox Nov 17 '17 at 04:43 PM

What exact problem you have right now?

avatar image redbox Nov 17 '17 at 04:46 PM

I only recommend to Set rotator with Roll = 0

avatar image Samuelb Nov 17 '17 at 04:51 PM

Ok i'll have to get back to this issue next week because im not at the office anymore. Thanks for the help so far, i'll post my results next week

avatar image Samuelb Nov 20 '17 at 09:13 PM

Ok, so i've managed to get the camera rotating correctly. The only issues is now that when my players surpass a certain rotation, the camera flips to the other side of the players and the players movement is affected by it, as i am using the cameras direction for the players controls. Any idea what could be wrong?

I'm getting each actors rotation, summing them together and dividing that by 2(Similarly to how the center point is calculated in the first picture). The division is clearly causing the camera to flip, but also makes the camera actor rotate correctly otherwise. I've tried normalizing the value but it doesn't seem to help.


avatar image redbox Nov 21 '17 at 07:37 AM

Not sure, but its some kind of lock. Camera uses characters location to calculate rotation, and characters uses camera rotation to calculate their rotation.

avatar image Samuelb Nov 23 '17 at 09:46 AM

thanks for the help, i'll keep trying.

avatar image Samuelb Nov 27 '17 at 12:14 PM
(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