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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Sidescroller Template: Can't figure out jumping

I'm trying to make my first game with Unreal. I figured I'd start simple so I booted up the sidescroller template and figured I'd go from there. I decided to make you jump higher when you hold the button, and found the variable JumpMaxHoldTime.

Whenever I set this variable to a non-zero value, it gets the desired effect, but it also makes the character able to jump infinitely without touching the ground. I've tried looking at the ACharacter class it inherits from, but couldn't find the cause of it. What's more, when I comment out some of the code in the template's character class...

 void AFitanGameCharacter::TouchStarted (const ETouchIndex::Type FingerIndex, const FVector Location)
 {
     // jump on any touch
     //Jump();
 
 }
 
 void AFitanGameCharacter::TouchStopped(const ETouchIndex::Type FingerIndex, const FVector Location)
 {
     //StopJumping();
 }

The character still jumps normally. I've rebuilt, testing with a log statement to make sure the rebuild worked, but the odd behaviours are consistent. From what I can tell there isn't any instance of a Jump() or StopJumping()

I was hoping someone could explain to me what's causing this behaviour.

Product Version: Not Selected
Tags:
more ▼

asked Nov 22 '14 at 05:38 AM in C++ Programming

avatar image

Slowmanrunning
199 15 18 35

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

1 answer: sort voted first

Alright, I figured out how to solve it.

ACharacter::Jump() does not properly check whether the player can jump or not before executing the jump. By including:

 virtual void Jump() override;

in the (GameName)Character.h file and then adding a modified jump function in (GameName)Character.cpp file:

 void AFitanGameCharacter::Jump()
 {
     if (CanJump())
     {
         bPressedJump = true;
         JumpKeyHoldTime = 0.0f;
     }
 }

Seems to have fixed the infinite jumping problem and has "holding jump" working as intended.

As for TouchStarted() and TouchStopped(), after reading their parameters I realized they were functions for jumping with a touch screen or similar interface and removed them from my class's .h and .cpp files.

more ▼

answered Nov 23 '14 at 07:00 AM

avatar image

Slowmanrunning
199 15 18 35

(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