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"

Could I get some help with this hookshot function?

I've been working on a function that takes in where you're looking and moves you in that direction, like a hookshot, which uses the third person code as a start. I think I have a good start here but in editor it does nothing.

code in sCharacter.cpp

 void AsCharacter::hookaim(float value)
 {
     if ( (Controller != NULL) && (value != 0.0f))
     {
         //find which way you we're looking
         const FRotator Rotation = Controller->GetControlRotation();
         const FRotator MyRotation(Rotation.Roll, Rotation.Yaw, Rotation.Pitch);
         //Move in that direction
         const FVector Direction = FRotationMatrix(MyRotation).GetUnitAxis(EAxis::X);
         //need this ^ to take all axis
         AddMovementInput(Direction, value);
     }
 }

This all compiles btw.

First of I'm not sure how to get FRotaionMatrix(MyRotation) to get X,Y and Z instead of just X, and plugged X in just to see if it works, it doesn't. I have set the function name in the editor project input settings to activate when left click is pressed.

Any ideas?

Product Version: Not Selected
Tags:
more ▼

asked May 17 '14 at 11:44 PM in C++ Programming

avatar image

GoodNewsEvery1
5 2 3 5

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

2 answers: sort voted first

First off, you won't be able to move vertically via AddMovementInput while your movement mode is "Falling" and lateral movement will be limited by your air control values. Setting the movement mode to "Flying" will allow you to do this, but it will also disable gravity which may or may not be acceptable. As Redshft mentioned, you can set the velocity directly as well, but that will not work in a networked environment since you'll be working around the input system. This may or may not be acceptable. If you need more specific behavior then you can create a custom movement mode in your movement component.

As far as your rotation issue goes, I think what you're probably looking for is GetForwardVector(). You can call this on any scene component, probably the camera would be your best bet here. However, I see that the method you are using ( FRotationMatrix(MyRotation).GetUnitAxis(EAxis::X); ) is what KismetMathLibrary does to find a forward vector. I suspect Controller->GetControlRotation(); might not be what you're expecting it to be, it might not be reliable.

more ▼

answered Sep 14 '17 at 06:53 PM

avatar image

SlimeQ
332 10 21 38

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

I believe the function APawn::AddMovementInput is used purely for ground movement. You would need to do something similar to the jump code in ACharacter and UCharacterMovementComponent in order for your character to move through the air. In other words, you'd have to set the movement mode to falling and set the velocity directly.

more ▼

answered May 19 '14 at 03:11 AM

avatar image

Redshft
36 1 2 4

(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