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"

Scaling up Character Component makes it fall through the floor

Preamble:

Hey guys!

So, I'm trying to make a BP script to make a character that is able to transform into other characters (with different sizes, move speeds, etc.)

First, I tried to do this by unpossessing and destructing the current actor and then spawning another actor in the same place and possessing it. But whatever I did, it would not maintain the camera pitch.

Then, I decided to use just one Character Blueprint, and change it's Skeletal Mesh, Animation BP, Camera Boom, and NavMovement Component properties during Gameplay. Everything was awesome, until I had to scale the Character Capsule Component, to scale the characters up and down.

The Main Problem:

When I have a character with, let's say, 1 in Z-Scale, and I scale it down to 0.1, the character floats and then lands. But the main problem (stated in the title) is that when I have a character that has 0.1 in Z-Scale, and scales it up to 1 back again, the character either stucks into the floor, or it falls beneath it.

Theory:

Actually, what is happening is that when we scale the Capsule Component, it scales with the pivot point in the center of the capsule. Thus, when we have a small capsule touching it's bottom in the floor, when we scale it up, the feet falls below the floor (and when we scale it down, the feet goes above the floor) and the character falls.

Questions:

  • Any ideas of how could this be solved?
  • Is there any way to change the Capsule Component Pivot Point to the bottom, so it scales in direction to the toes, instead of in direction to the center of the character?
  • A not so elegant solution: check if the character is below the floor after transformation and if it is, bring it up. How to do it?
  • Is there any other solution that I'm not thinking about?

PS: If you need my Blueprint of what I've achieved so far, let me know! =]

P-PS: If you have any solutions that are not related to Blueprints (such as a C++ implementation), please, share it also! I have no problem understanding C++. I posted in the Blueprint section just because I'm already using Blueprints. =P

P-P-PS: It's never too late to answer! I'll be working with other stuff while I do not manage to solve it, so feel free to answer it even if it's been over a month (of course, when it's solved, I will post it back here!).

Thanks!!

Product Version: UE 4.14
Tags:
more ▼

asked Dec 16 '16 at 08:45 PM in Blueprint Scripting

avatar image

godofred
3 2 3

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

4 answers: sort voted first

You could also do, when the condition is met for turning your scale from .1 to 1, have the actor move up a little on the Z axis to make up for the distance of getting stuck in the floor.

more ▼

answered Dec 20 '16 at 05:39 PM

avatar image

shotty46290
348 12 7 21

avatar image godofred Dec 20 '16 at 07:51 PM

This would probably work! The thing is, I plan to have a lot of interchangeable characters, and this would require a lot of try-and-error for each character to make it right. Nonetheless, it is a good and simple solution for someone who wants to change between only two characters in-game. If hiiii5's solution doesn't work, I will try this, and try to make it as modular as possible, though. Thanks for the insight!

avatar image godofred Dec 21 '16 at 06:53 AM

Yeah man, that was the way to go! And much simpler than I thought it would be to get modular! It just required some basic math =P

If you wish to turn your comment into a complete answer, I'll mark it as correct. I'll also post my solution, though, just to let people know exactly how I managed to solve it. ^^

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

The quickest idea that comes to mind has to do with the objects origin point. So lets say you have the objects origin at the center so it scales uniformly, this would then entail that if you scale on the Z axis as stated you would scale that object both up and down essentially. So when you scale your player and it falls this is probably incorrect.

To go about fixing it I would change the origin point to the very bottom of the object so that it only scales up and down and everything else should be uniform. An easy way to change this without running into a modelling program would be to make a parent object on top of the FirstPerson BP(you will probably need to change the way some things behave but I am not sure). Then translate up all of the bp so that it is locally above that parent origin.

If I wasn't very clear on this, I apologize, I'm not in the engine right now!

more ▼

answered Dec 20 '16 at 06:32 AM

avatar image

hiiii5
10 1 3

avatar image godofred Dec 20 '16 at 07:52 PM

This seems really promising!! I will try to do this later today and mark your answer as correct if it works!

Thanks!!

avatar image godofred Dec 21 '16 at 06:42 AM

So, an update: I tried to that, but when you create a new Character Blueprint Class, the CapsuleComponent (root) and it's childs (Arrow and Mesh components) are Inherited. I don't know why, but you can't change the hierarchy of inherited components (at least in UE 4.14.1).

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

So, it's finally solved!

Following shotty46290's suggestion, I decided to move the character in the Z-axis after scaling it, since there seems to be no easy way to change the pivot point when working with Character Blueprints.

The key to make it modular was finding a way to get the exact spot to be translated in a programmatic way. I decided to go the simplest way: find how much has the character base translated after scaling it, and then offset the actor by that amount with opposite sign.

It's better to understand with pictures, so there you go!

IMPORTANT Note: "New Scale" is a float that can be any value in the range (0,+inf), bounds not included! It is passed as an argument to the "ChangeCharacter" function.

IMPORTANT Note 2: It is also an "absolute" value. Example: when you have a Number 1 character with New Scale=1, change to character Number 2 with New Scale=0.1, and then change to character Number 3 also with New Scale to 0.1, the Number 3 character WILL NOT be 0.01 in scale relative to the first one. It will be the same size as the Number 2 character.

alt text

alt text

Thanks for your time!!

more ▼

answered Dec 21 '16 at 08:44 AM

avatar image

godofred
3 2 3

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

You could also do, when the condition is met for turning your scale from .1 to 1, have the actor move up a little on the Z axis to make up for the distance of getting stuck in the floor.

Here's your answer, glad you got it working, and good luck in your future programming adventures.

more ▼

answered Dec 21 '16 at 11:33 AM

avatar image

shotty46290
348 12 7 21

(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