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"

How to make a camera orbit a planet and always look towards a player in the world while maintaining the player's forward vector at the top of the camera?

My current idea to use a camera attached to a spring arm, attached to the world, this maintains the correct position for the camera, but the rotation of the camera towards the player is wrong. If any one has a clue on how I could use an easier technique on getting a camera to orbit the cube planet (directly above the player), while the player is constantly moving, and to have the player's forward vector pointing towards the top of the camera's point of view, please do share.

I have tried placing a camera on the player, but then the world isn't centered to the camera, unlike the photos below. By placing the camera behind the character, it does achieve the right rotation that is desired. I have also tried a free floating camera, unattached to either the planet or the character, and was able to achieve this by extending a vector from the center of the world (0,0,0) towards the player, and extended it further out till the radius of desired range of the camera. This worked the same as below, but it also ran into the same problem with camera rotation.

alt text alt text alt text alt text alt text

Product Version: UE 4.9
Tags:
camera bp.png (207.4 kB)
example_01.png (609.5 kB)
example_02.png (656.2 kB)
example_03.png (573.6 kB)
example_04.png (568.5 kB)
more ▼

asked Aug 05 '16 at 08:47 AM in Using UE4

avatar image

DreamPhantom
3 4 7

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

1 answer: sort voted first

The answer depends on what is the most important for you. Setting it on the planet allows for always looking at the planet and you have to constantly update the position of the camera such that the planet location, player location and camera location are on a line. You can do this by getting a vector from the planet to the player, normalize and multiply it using a scalar value that is your radius. You also have to set the rotation like you are doing above.

The other option is to attach it to the pawn and add the offset rotation between the vector from the planet to the player and the current spring arm vector.

The former uses your code and allows for more customization of your camera location and rotation, but it will always focus the planet. The latter allows you to easily change focus around which you want to rotate or focus.

The code complexity is about the same.

more ▼

answered Aug 05 '16 at 09:01 AM

avatar image

NoobsDeSroobs
2.7k 106 34 176

avatar image DreamPhantom Aug 05 '16 at 06:23 PM

Thanks, that gave me an idea to try. I think the solution is to simply remove the "Look at Rotation" and replace it with a different type of rotation update. The "Look at Rotation" equalizes the rotation to always have the up vector for the camera to be up, which should be the normal feature, but doesn't work in my case. So this means that the spring arm wouldn't be needed either, since the whole point of the spring arm was to give it a set length for the radius. I'll retry to make a BP_Cam that gets its position by extending the vector from the world to the player to a set length like I tried before. Then find a new way to stabilize the rotation to look at the player, through to the world, to have the same view vector as the images above.

If any one has a clue on how to do the second portion about the angle stabilization, that would be nice.

@NoobsDeSroobs Thanks.

(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