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"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

Character Continously Jumping

Hi,

I am trying to program some jump functionality with my character. When i play he is not jumping, but on the initial jump button when its pressed he jumps as intended but then carries on jumping after which is not intended.

TrainingCharacter.h

     UPROPERTY(BlueprintReadOnly, Category = "Character")
 bool bCanJump;

 UPROPERTY(BlueprintReadOnly, Category = "Character")
 bool bIsJumping;

 /** The character starts jumping*/
 virtual void JumpStart();

 /** The character stops jumping*/
 virtual void JumpStop();


TrainingCharacter.cpp

 ATrainingCharacter::ATrainingCharacter(const FObjectInitializer& ObjectInitializer)
     : Super(ObjectInitializer)
 {
         this->bCanJump = false;
     this->bIsJumping = false;
 }
 
 void ATrainingCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
 {
 
     InputComponent->BindAction("Jump", IE_Pressed, this, &ATrainingCharacter::JumpStart);
     InputComponent->BindAction("Jump", IE_Released, this, &ATrainingCharacter::JumpStop);
 }
 
 void ATrainingCharacter::JumpStart()
 {
     this->bCanJump = true;
 }
 void ATrainingCharacter::JumpStop()
 {
     this->bCanJump = false;
 }
 



MyAnimInstance.h

 UPROPERTY(EditDefaultsOnly, BluePrintReadOnly, Category = "Character")
 bool bCanJump;


MyAnimInstance.cpp

 void UMyAnimInstance::BlueprintUpdateAnimation(float DeltaTimeX)
 {
     Super::BlueprintUpdateAnimation(DeltaTimeX);
 
     if (this->Character != NULL)
     {
         this->bCanJump = this->Character->bCanJump;
     }
 }
 

Locomotion Blueprints

http://i.imgur.com/xCLMtKN.png http://i.imgur.com/wEWa2HO.png http://i.imgur.com/ga7TYOS.png http://i.imgur.com/sLho8n3.png

This is all i have done on jumping as this project is created from scratch. Can someone tell me what i need to do to stop him from constantly jumping. My initial idea was to have a variable of "canJump" be set to true when ever a person hits the jump button, then on release it sets the "canJump" button back to false.

Product Version: Not Selected
Tags:
more ▼

asked Mar 17 '15 at 08:23 AM in C++ Programming

avatar image

OfficialKHAN
1 2 8 8

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

1 answer: sort voted first

i think instead of just set the bCanJumpFlag. in the character class there is a function named :: - Jump() - StopJumping()

you can use that in your press event.

and i also wondering about your animation.. are you using the state machine?? (locomotion??) i think you had to take a look at the thirdpersoncharacter from unreal. because i think your problem also implies the animation (if you just stay in the jump animation state after you jump).

cherrs...

more ▼

answered Mar 17 '15 at 08:46 AM

avatar image

mirsabayu
202 15 24 35

avatar image OfficialKHAN Mar 17 '15 at 09:25 AM

@mirsabayu

Why would i need to use the Jump() and StopJumping() functions? What do they do? Can i not just re-create these in c++ as i think they use some blueprint functionality right?

Sorry, i don't understand what you mean regarding the animation. If you check my question you will see i provided links of the locomotion. Can you please explain what you mean?

avatar image mirsabayu Mar 17 '15 at 09:34 AM

/** Make the character jump on the next update.
If you want your character to jump according to the time that the jump key is held, then you can set JumpKeyHoldTime to some non-zero value. Make sure in this case to call StopJumping() when you want the jump's z-velocity to stop being applied (such as on a button up event), otherwise the character will carry on receiving the velocity until JumpKeyHoldTime is reached. */ UFUNCTION(BlueprintCallable, Category="Pawn|Character") virtual void Jump();

 /** 
  * Stop the character from jumping on the next update. 
  * Call this from an input event (such as a button 'up' event) to cease applying
  * jump Z-velocity. If this is not called, then jump z-velocity will be applied
  * until JumpMaxHoldTime is reached.
  */
 UFUNCTION(BlueprintCallable, Category="Pawn|Character")
 virtual void StopJumping();

== the implementation ==

void ACharacter::Jump() { bPressedJump = true; JumpKeyHoldTime = 0.0f; }

void ACharacter::StopJumping() { bPressedJump = false; JumpKeyHoldTime = 0.0f; }

from ACharacter class in cpp, maybe it can help. so it's not a blueprint. it was a cpp function that expose in blueprint;

and as for animation. is it a state in the state machine?? (and what stat??) i think it's better if you provide the animgraph and also the statemachine in that.

avatar image OfficialKHAN Mar 17 '15 at 10:11 AM

Right i get this. In the AnimBlueprint i have retargeted to my custom animblueprint i created in c++. So the variable in the eventgraph "Jump Button Down" does not compile as it can't find it. How can i fix this? I have tried searching for where this is initialised in the Character class but i can't seem to find it

ive alrdy provided with the state machine its here. http://i.imgur.com/xCLMtKN.png

And the animgraph is only the Locomotion connecting to final animation pose.

avatar image mirsabayu Mar 17 '15 at 10:27 AM

sorry, i seems can't find your eventgraph. i think if you use your own customAnimInstance. i think the problem, is really gonna be simpler. because you can call your animationInstance using the skeletalMesh on your character class. but anyway, maybe i seems not really understand what you wanted to achieve. as i see in your stateMachine/locomotion what i see is just a three state right. so when it want to jump in the transition condition you feed it with a bool that you get from charactermovement->isFalling() right?? and that goes the same with the landing (just feed the not IsFalling in the transition condition). - but maybe you will not get a very satisfying animation (because what i know, like thirdperson project give us. it break to 3 state (jumpstart, jumploop, and jumpend)

sorry if it not help much jejeje

avatar image OfficialKHAN Mar 17 '15 at 10:30 AM

Thnx anyway hopefully someone else might know

(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