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 do I go about creating a camera that follows the currently possessed pawn?

Hello,

I am trying to create a camera for my top down game. It is not a point and click strategy game. I am trying to achieve a couple of different things here

1) I need the camera to follow the player on x and y only. I do not want the camera to go up and down everytime the player jumps

2) I need the camera to follow the currently possessed pawn. I have vehicles in my game which the player can possess. I do not want to have a camera for each and every vehicle that I need to modify. I would like to have a global camera that does this.

Is it possible to create such a camera in blueprints without having to use "Set Actor Location" because that introduces a lot of jerkiness when moving around.

Basically I want to attach the camera to the currently possessed pawn and want to ignore the pawns rotation in all axes and the scale in the z axis. I am trying to create a GTA 2 style camera http://youtu.be/MaBlgdox6-Q?t=1m

I guess as a bonus question, how would I get the camera to lead the player when they are inside a vehicle like in the video?

Any help is much appreciated! :)

Product Version: Not Selected
Tags:
more ▼

asked Jul 08 '14 at 01:40 PM in Using UE4

avatar image

HypnoticShark
617 23 29 47

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

1 answer: sort voted first

Hey HypnoticShark,

Though I imagine you're not using the Top Down template, you might want to take a look at the camera settings for the MyCharacter Blueprint in that template. Having a Spring Arm component with Absolute Rotation instead of Relative will maintain the x and y position of your camera even if your character rotates.

alt text

To keep the same camera set up for each vehicle, you can create your own vehicle sub-class with a specific camera, and then derive each different car type from that class. Then you'll only need to make adjustments to the sub-class camera rather than to every vehicle individually. If you set the camera up the same as you have it for your character, changing possession to a car from your character will maintain the same view.

To get your camera to lead the vehicle, you'll need to do some blueprint work inside your vehicle sub-class. You can Lerp the camera component to a position in front of the vehicle, and Lerp to new positions as the car is rotated. You'll need to experiment with this to get it to look and feel the way you want it.

Jumping and maintaining the same camera z position is somewhat more complicated, and may involve a few different methods depending on how you're setting up your game. The problem is that if you're using the built in Character class for your character Blueprint, the Jump command actually moves the whole character capsule and the camera with it. You can write your own jump functionality so that it only moves the character mesh instead of the whole character, but that may lead to collision issues with your levels if jumping is anything more than aesthetic, and may involve significantly more work to function correctly. An easier option is to create a Camera Blocking Volume above your level directly above your desired camera height so that the camera cannot pass above it. Enable Do Collision Test in the Spring Arm component and you'll get what you're looking for... but this will only work properly if your camera is directly above your character.

Hope all that helps! Let me know if you have more questions.

Ben Halliday

more ▼

answered Jul 08 '14 at 11:14 PM

avatar image HypnoticShark Jul 09 '14 at 06:58 AM

That is a fantastic response. Thanks Ben! I did manage to solve this problem a different way (all three of them) and will post my version of it up here soon after I do some clean up and comment it. I found this easy to manage but I do not know how efficient it is, but it works for me.

(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