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"

Leap/Launch pawn forward.


I'm trying to make the pawn leap / jump forward in the direction that they're facing. So if the player is looking upwards and this function happens, they will be pushed with velocity upwards (because it's the direction they're facing).

Right now, I have the code below which works, but it doesn't work for all directions, it's just forward - I'd be greatful if somebody could point me in the direction of how I can change this to work to the desired effect above.

 const FVector ForwardVec = GetActorForwardVector() * 1800 + FVector(0, 0, 1.0f);
 LaunchCharacter(ForwardVec, true, true);


Product Version: UE 4.9
more ▼

asked Jan 15 '16 at 12:18 PM in C++ Programming

avatar image

13 2 5 10

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

1 answer: sort voted first

You will have to use the camera orientation instead of the actor's forward vector (forward vector is orthogonal to the xy-plane if I recall correctly), e.g.

 FVector viewLoc = GetPawnViewLocation();
 FRotator viewRot = GetViewRotation().GetNormalized();
 FVector forceVector = viewLoc + viewRot.Vector() * 1800.0f;

P.S. You might need to adjust the retrieved ViewRotation's pitch to be larger than zero to handle the case when the mouse is pointing downwards.

more ▼

answered Jan 15 '16 at 12:34 PM

avatar image

2.6k 95 41 111

avatar image BannockUK Jan 15 '16 at 01:04 PM

You are excellent! This put me on the right path. For those who are curious, this is what worked for me.

 FRotator viewRot = GetViewRotation().GetNormalized();
 FVector viewDir = this->GetActorLocation() - this->GetPawnViewLocation();
 FVector forceVector = viewDir + viewRot.Vector() * 1800.0f;
 LaunchCharacter(forceVector, true, true);

This was for a multiplayer game fyi.

Thank you Staticvoidlol!

(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