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"

Character Movement and Water

Hi,

 **I have made a Island and it's surrounded by water and you can walk on water. How do you make it so your Character can swim in the water? Is there already Character Movement for swimming? If there is not how would I make the Character Movement for swimming? I placed a plane down and then added the Ocean Water texture to it. Is there a better way I could make a Ocean?**

Thanks for your Help! :)

Product Version: Not Selected
Tags:
more ▼

asked Jul 05 '14 at 12:13 PM in Using UE4

avatar image

TheCreativeGames
50 25 22 28

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

2 answers: sort voted first

RESOLVED

more ▼

answered Jul 20 '14 at 03:05 PM

avatar image

TheCreativeGames
50 25 22 28

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

Hi TheCreativeGames,

Creating water is best done through physics volumes (you can find those among the other volumes in the leftmost bar of your editor). These volumes can be tweaked to simulate water physics and have a tickbox to make certain blueprint and C++ functions aware that they are water volumes.

You will need to implement some custom movement in water inside your Character, such as swimming upwards instead of jumping, or not sinking like a stone. This is fairly easy to do - I use this for simple upwards motion while holding the space bar in water:

 //register swim up function
     InputComponent->BindAxis("SwimUp", this, &ACharacter::SwimUp);
 
 void ACharacter::SwimUp(float Value)
     {
         if (CharacterMovement->IsInWater()) //if the player is in water...
         {
             FRotator Rotation = Controller->GetControlRotation();
             //limit pitch when walking, swimming or falling
             if (CharacterMovement->IsMovingOnGround() || CharacterMovement->IsFalling() || CharacterMovement -> IsInWater())
             {
                 Rotation.Pitch = 0.0f;
             }
             const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::Z);
     
             //swim up
             AddMovementInput(Direction, Value);
         }
     }
 

I also suggest coupling it with a PostProcessingVolume that alters the light colour and adds gaussian blur to make the player aware that they have entered water :)

more ▼

answered Jul 05 '14 at 01:04 PM

avatar image

Jargon
808 39 30 65

avatar image TheCreativeGames Jul 05 '14 at 01:28 PM

Thanks So Much for your help! I am using Blueprints instead of C++. Could I possibly send you my game folder and you could do this for me in Blueprints? Or what would I do in the Blueprints could you tell me step by step? Thank You!

avatar image Jargon Jul 05 '14 at 01:44 PM

It shouldn't be too hard to do this in Blueprints ^.=.^ The general gist is this:

  1. If the player presses his Space Bar..

  2. Check if he's inside a water volume (a water volume is a physics volume with the "Water Volume" checkbox ticked)

  3. If he/she is, Get the control rotation (that's the camera's rotation)

  4. Set the pitch to 0 if the player is in water, falling or walking on the ground (to prevent the space bar from making you swim backwards instead of up)

  5. Get the Z vector from the rotation via a Rotation Matrix (this is the direction, up in this case)

  6. Add movement in that direction

I haven't worked a lot with blueprints, so I'm not absolutely sure how to set this up, node-by-node - however, it should be relatively simple to just modify what you have ^.=.^

If you get stuck, you can add me on Skype (rumptrollet) and I'll have a look.

avatar image Cultusfit Feb 09 '19 at 05:05 PM

Wish you would have filled this out. The water volumes and such aren't too difficult but there seems to be a lack of setting up the controls very well.

I'm all blue print and mobile. So i was just going to set "forward" to same location camera is facing. Yet nothing I seem to try works. I STILL just move like I am flat on the ground

(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