Material - Squashing in a material

Hi, I am trying to get a material to squash into a hit point. I have no trouble passing hit and normal information to the material but I am having a problem moving the pixels toward the hit point along the normal. I also want to push the pixels toward the hit point but not have them go beyond a “floor”. The attached picture shows what I would like to happen.

Anyone have any ideas on how to accomplish this in a material?

Hey guys, I have had no luck since my last post. Any ideas?

1 Like

I think this should do it

Between 5 and 10 is a good amount to get a noticable effect

ball

The vector needs to be specified local to the ball. So, for instance, shrinking on Z, is the ball’s Z, not world Z. It also works regardless of ball orientation.

1 Like

Thank you @ClockworkOcean , this is an awesome start. The only thing it needs is to squash into the hit location. The example you show squashes into the middle of the sphere. If I multiply the normal by the sphere’s radius, I think I can subtract that from the World position to reposition the sphere to squash into the hit location. I will attempt it this evening and report back here.

1 Like

When it lands, you need to send the normal to the material parameter. It should work from there…

@ClockworkOcean Sorry, I misunderstood. I will try this evening and report back. Thank you once again!

1 Like

I think I am on the right path now. Here is the result:
gifForUnrealForums

It’s a bit crude at the moment but notice how the squash happens and it also happens at the hit point and not the middle of the sphere.

Here’s how I did it (Thanks to @ClockworkOcean for the help!):

Material:

On hit, the ball blueprint sends a hit normal and then plays a timeline which adjusts the “Amount” parameter. In the material, The translationMax parameter is based on the size of the ball.

How I’d like to improve this:

  • I’d like to stretch on a perpendicular plane. So for example, if the squash happens in the Z plane, I’d like to stretch the material a bit in the X and Y planes. This is difficult because I don’t really know how to create perpendicular planes, let alone stretch them if I did!
  • The timeline needs to be tweaked but I think that is achievable.
  • I like the look of Clockwork’s squash better than mine, but I just couldn’t get it to work with translation. if I could…

The nice thing about this approach is that the ball can rotate and the squash can happen in the direction I need it to while rotating; the squash doesn’t also rotate! I did try a skeletal mesh approach to solve this but currently it is beyond my abilities.

I will mark as solved but any suggestions for improvement are appreciated!

1 Like

From the pic, it’s not working correctly. It should ( and does for me ) work like a normal ball. I’m a bit pushed for time rn, but will come back later…

Can you show how you’re passing the parameter? ( I mean, I know how that works of course, but where are you getting the value? )

Ah, I see you’ve changed the material, so that is probably why it’s not working :slight_smile:

I set it up so all you have to do is pass the parameter…

Here is the BP that is passing the values. Note that ImpactNormal is created from the HitResult.

Yes, that’s what I was expecting, but you can just the param in my material, and I think it should work :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.