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 up crouching in UE?

Hey! I have been having some difficulty on getting a good crouch going for my game. I am using this code at the moment, which works pretty well:

 void AFPSCharacter::StartCrouch()
 {
     if (CharacterMovement->IsMovingOnGround())
     {
     isCrouched = true;
     CharacterMovement->bWantsToCrouch = true;
     }
 }
 
 void AFPSCharacter::EndCrouch()
 {
     if (CharacterMovement->IsMovingOnGround())
     {
     isCrouched = false;
     CharacterMovement->bWantsToCrouch = false;
     }
 }
 

The problem is that the player crouches immediatly, without any type of crouching motion or delay, so it looks very unnatural. This on the other hand, works perfectly....

 void AInstinctCharacter::StartCrouch()
 {
     if (CharacterMovement->IsMovingOnGround())
     {
     Crouch();
     }
 }
 
 void AInstinctCharacter::EndCrouch()
 {
     if (CharacterMovement->IsMovingOnGround())
     {
     UnCrouch(true);
     }
 }

...but "EndCrouch()" does not work for whatever reason. Anyone know why? Thank you in advance! I implemented it as follows:

     InputComponent->BindAction("Crouch", IE_Pressed, this, &AFPSCharacter::StartCrouch);
     InputComponent->BindAction("Crouch", IE_Released, this, &AFPSCharacter::EndCrouch);

Product Version: Not Selected
Tags:
more ▼

asked Jun 01 '14 at 08:21 PM in C++ Programming

avatar image

Borzi
174 43 39 47

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

1 answer: sort voted first

Hi Borzi,

In EndCrouch(), change the line UnCrouch(true); to UnCrouch(); and see if that resolves your issue.

more ▼

answered Jun 02 '14 at 11:29 PM

avatar image

Tim C ♦♦ STAFF
18.2k 423 69 286

avatar image Borzi Jun 03 '14 at 02:47 PM

Perfect, thank you.

avatar image Tim C ♦♦ STAFF Jun 03 '14 at 03:51 PM

Hi Borzi,

Keep in mind that the generally preferred method for making a character crouch is by setting the value of bWantsToCrouch to true (and false to make the character return to its normal stance). However, if the method above meets your needs, then you should be fine.

avatar image Borzi Jun 04 '14 at 06:59 AM

Yeah, it works a lot better actually.

(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