Hello
I am working on an Antman type character and I am able to change the scale of my character with the push of a button. However, when I shrink my character, he then falls from mid-air down to the ground. Is there a way to transform location for just the z-axis? Basically, when I shrink the character I want him to shrink down to the ground rather than shrink in the air and fall.
Thanks
I am unsure exactly how you have your setup, but I assume your scaling your character over time and using a blueprint derived from the “character” class. Your issue is that the root component is the middle of the capsule collider, so when you are scaling it the height of the capsule is being scaled around the center point.
You will likely want to linetrace towards the ground below the character and set the characters position to the impact point + (the capsule half height * the actor scale).If you can provide more of your setup I can help with a more specific answer.
The problem is the pivot point. The point from which the object translates, rotates, or scales. You need to go into your 3D editor software, move the pivot point to the bottom-center (or bottom corner) of your mesh, and reimport your mesh. Now, when you scale or rotate, it’ll be done from that point. Specifically, for scaling along the Z axis, your character will stay on the ground.
This is my current setup. It is very basic. I am just using a button input to transform my character’s scale down to 1/10 its normal size. Unfortunately I am very new to this, so I dont know how to do a linetrace.
I am just using the starter content mesh. Is there a way to change this pivot point from UE, or would I have to export the mesh into Blender or some other program?
So for some context of what is going on, here is an image of the default character class with a mesh just added in, as you can see the character at (0,0,0) is standing in the middle of the capsule collider which is used for collision detection.
Next I have moved the character down by the capsule half height so the feet align with the bottom of the capsule collide, but note that in it’s relative space the center of the capsule collider is still at (0,0,0)
When you scale it is around the (0,0,0) relative space coordinate so that is why the ground suddenly dissapears out from under your character.
To do a line trace You can do the following, though I chose 100 units above and below arbitrarily just knowing it is larger than the capsule half height, you may need to adjust as you see fit:
Hope this helps.
Can you show me a picture of the mesh in the world with it in movement/translate mode so I can see the pivot point? If it is indeed not anchored to the bottom, you’d have to export it, change the pivot, and reimport it. But it seems strange that Epic’s own asset wouldn’t have a good pivot point. Maybe something else is happening.
DR Gage, the issue is not with the pivot point of the mesh, but the pivot point of the capsule collider that is the root component of the Character class. bhobgood could simple scale the skeletal mesh but then to collisions would be entirely off. Take a look at my answer for images of what I mean.
I put in the line trace and thanks for the explanation as it was very easy to understand. It works perfectly a few times, but then for some reason it stops working after a few times and my character gets stuck in the floor.
It’s likely because it isn’t colliding with the floor or something, Change the debug type to persistent or whatever and it should prove illuminating.
That makes sense. Nice answer. You could also, as an alternative, translate the character downward relative to the scaling, and do it at the same time via Timeline, to make sure your character’s feet remain in whatever position they were prior to the scaling. This would also allow scaling the character at any time, even in mid air, and would keep the adjustment contained only to the character’s relative position.
Thanks Noah, I was able to make it work. I appreciate it.