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 can I set this up in c++?

Like thealt text title said i want to know how to set this blueprint in C++.

Product Version: Not Selected
Tags:
1.png (87.4 kB)
more ▼

asked Feb 23 '15 at 04:44 PM in C++ Programming

avatar image

Huako
30 3 5 9

avatar image Huako Feb 23 '15 at 05:00 PM

Correct math i think xD void ACharacter::ReceiveBeginPlay() { FRotator Adjustment = FollowCamera->GetComponentRotation();

 Adjustment.Pitch += 10;

 FRotator MakeRot(Adjustment.Pitch, Adjustment.Yaw, Adjustment.Roll);

 FVector GetForwardVector = MakeRot.Vector();
 
 float Distance = 420;

 FVector MultiplyVectorFloat(GetForwardVector * Distance);

 FVector LocationFinal = FollowCamera->GetComponentLocation();

 FVector Add_VectorVector(LocationFinal + MultiplyVectorFloat);

 FVector NewLocation = Add_VectorVector;
avatar image spazchicken Feb 24 '15 at 12:05 AM

This is what you do to create the camera in the player class:

header:

     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
         class UCameraComponent* SideViewCameraComponent;
     
         /** Camera boom positioning the camera beside the character */
         UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
         class USpringArmComponent* CameraBoom;



CPP:

  // Don't rotate when the controller rotates.
         bUseControllerRotationPitch = false;
         bUseControllerRotationYaw = false;
         bUseControllerRotationRoll = false;
     
         // Create a camera boom attached to the root (capsule)
         CameraBoom = ObjectInitializer.CreateDefaultSubobject<USpringArmComponent>(this, TEXT("CameraBoom"));
         CameraBoom->AttachTo(RootComponent);
         CameraBoom->bAbsoluteRotation = true; // Rotation of the character should not affect rotation of boom
         CameraBoom->TargetArmLength = 750.f;
         CameraBoom->SocketOffset = FVector(0.f,0.f,75.f);
         CameraBoom->RelativeRotation = FRotator(0.f,180.f,0.f);
     
         // Create a camera and attach to boom
         SideViewCameraComponent = ObjectInitializer.CreateDefaultSubobject<UCameraComponent>(this, TEXT("SideViewCamera"));
         SideViewCameraComponent->AttachTo(CameraBoom, USpringArmComponent::SocketName);
         SideViewCameraComponent->bUsePawnControlRotation = false; // We don't want the controller rotating the camera



avatar image spazchicken Feb 23 '15 at 11:44 PM

Sorry I accidently deleted my comment so I don't know if you commented back(kids are diving me crazy atm!). I posted that i didn't know anything about bp scripting so I don't know what's going on when i look at it really. Is the camera attached to the object you are trying to offset it to? Or is the camera if a different bp/class? Did you create a spring arm?

avatar image Huako Feb 24 '15 at 12:06 AM

yes im trying to do Both ^^

avatar image spazchicken Feb 24 '15 at 12:20 AM

Yo have top create a spring arm and camera component, attach the spring arm it to the player/object, then attach the camera object/component to the springarm.

After that, you can change the location./offset of the spring arm(or camera component) to the objects it attached to for example:

CameraBoom->relativerotation.Pitch = 50.0f;

OR

CameraCompoent->relativerotation.Pitch = 50.0f;

avatar image Huako Feb 24 '15 at 12:23 AM

but what happens to the player camera already created?

avatar image spazchicken Feb 24 '15 at 12:27 AM

What I wrote is just an example. Did you create a spring arm to your camera?

avatar image Huako Feb 24 '15 at 12:33 AM

I tried it with both the follow camera and camera boom, both sent the object far away and the character, it also does not attach well this are the lines that im working with.

 AACharacter::Target->SetWorldLocation(NewLocation, false);

and

AACharacter::Target->AttachTo(CameraBoom, InSocketName = NAME_None, EAttachLocation::Type(EAttachLocation::KeepWorldPosition), true);

avatar image spazchicken Feb 24 '15 at 01:02 AM

Are you working with a blueprint? Is the AACharacter part of the same class as the CameraComponent and Cameraboom(I'm assuming so but just in case)

avatar image Huako Feb 24 '15 at 01:12 AM

yes is a TSubobject of follow camera

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

1 answer: sort voted first

To get the player camera from another class, you use

FVector CameraLocation = GEngine->GetFirstLocalPlayerController(GetWorld())->PlayerCameraManager->GetCameraLocation();

FRotator CameraRotation = GEngine->GetFirstLocalPlayerController(GetWorld())->PlayerCameraManager->GetCameraRotation();

To "offset" it, you add a rotation amount: myComponent->RelativeRotation.Pitch = CameraRotation.Pitch + 90.0f;

more ▼

answered Feb 24 '15 at 01:21 AM

avatar image

spazchicken
447 35 20 53

avatar image Huako Feb 24 '15 at 01:29 AM

tyvm for the help

avatar image spazchicken Feb 24 '15 at 01:56 AM

did you get it to work? :o

avatar image Huako Feb 24 '15 at 02:13 AM

yeah but now im stuck in some other part but thats for another day ^^

(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