Coin object Event Tick: On collision I rotate coin faster and lift it up to my character, but how to shrink/scale it down also?

This is my Event Graph for my “Coin” object. If I collide with it, I set a var “beingPickedUp” to True and this triggers in my Event Tick:

This speeds up coin rotation and lifts up off the ground to me just fine but I want to also make it shrink from it’s current size to nothing as it reaches the end of the animation before I destroy it.
(PS. I know I could have done this better with timelines, but I just manipulate the rotation speed and let the Event Tick chip away at rotating it and lifting it faster…)

How do I get the current scale and decrease it, incrementally? Again, I’m using the Event Tick, so just chipping away at the size/scale each tick is fine.
Thanks in advance!

Hi there and welcome,

You don’t need to get the current scale, unless you are messing with that elsewhere you can assume it was what you last set it to.

This node arrangement normalises your Z velocity (0 → 350) and inverts it, giving you number between 1 and 0, 1 at the start of the ‘pickup’ transiting to 0 as you destroy it.
Should suffice?


[Note: May want to scale just the mesh… depends]

Okay I set it to this now:

but when I walk over the coin, it just sits there and does nothing.
I’m fairly new to UE so I apologize if I’m not doing something obvious. Thanks again!

Subtract node is wired wrong, which would be scaling it up massively.

But you are no longer changing the coin’s velocity, so of course the code I providing which taps this change does not work.

My mistake, actually the minus node being wired wrong means it would be scaling from -1 to 0, and I assume negative values are ignored. So that alone might give you the observed behaviour.

But you still need to do everything you were doing before, the code I provided set’s the scale based on the velocities Z component, so without that happening, no change.

I should probably note that this is not how I would do any of this, but you already had a partial implementation you are happy with, so I provided something ‘compatible’.

Do try to understand it if you are going to use it, you need to integrate it with your project and if you don’t understand how it works, then that is going to be difficult.

I re-read your replies and understand now.
I went back and wired it up to the existing flow I had there.
In the end, I could either get the coin to shrink using your example OR do the previous thing it was doing (rotating faster and rising up) – but not both at the same time.

I think there’s some weird relationship between Scale and the Set Physics Angular Velocity / Set Physics Linear Velocity. Even though I was just changing scale, it would stop or override the rotation and Velocity.

Anyway, you mentioned that you would do this different – in a few words, how you would implement a collision that makes the coin spin faster, rise up, and shrink until it’s destroyed?

I would define a (constant) ‘time to pickup’ somewhere, and after the pickup flag is set start accumulating the seen delta times, this accumulated time divided by the time to pickup is a 0.0 → 1.0 value that tells you how far through the transition you are. I would then use this value to determine the coins Z pos, current rotation and scale, and set them. No physics.

A little more complicated for the z pos and rotation as they are not linear like the scale, if an appropriately simple mathematical mapping can not be found, a curve could be used here (or may even be preferable).

But of course whether that would work for you depends on your particular use case, which I only have partial information on :slight_smile: I don’t see the need for physics on these coins, assuming they do nothing other than exist to be picked up. But maybe that is a bad assumption.

Yeah, that seems pretty clean.
The reason I wanted the physics enabled is because when I click to DROP the coins, the physics basically does the drop/bounce nicely. When the Coin object is first spawned, it has a faster starting rotation which is done in Event Tick, but it starts moving that rotation variable down to a variable called TargetRotation speed (you’ll notice theyre spinning fast and then settle on a medium-slow spin). Then walking picks them up and they’re doing everything but shrinking on the pickup collision.
Recording 2024-08-05 at 22.27.42

My ultimate goal is not only to have them shrink into your body, but also chase you (e.g. if you run past the coin which triggers the pickup, the coin should ALSO kind of chase you a bit faster to meet up with your running body).

Note: because of the low framerate of the gif, its hard to see the fast rotation on the drop and the sped up rotation on pickup… but you get it)

Another gif example (used gifcap.dev btw… great client side browser tool) :
Recording 2024-08-05 at 22.38.04

Hi, sorry for the late response, I wanted to play around with the whole angular velocity and scale thing as it didn’t seem right that scale should mess things up, but I didn’t have time yesterday.

I have whipped up a little test now, a very simple one, just testing angular velocity and scaling. Coin (with physics) spins, and is constantly scaled up and down over time.

The physics (as expected) caused several problems. I fixed what I could with settings and fudged the rest. Coin falling over: scaled the simple collision ‘width’. Tiny angular variations after the bounce messing the rotation and ‘ballooning’ out over time: reset rotation after hit. Bounce messing up Angular Vel: reset it after hit. Coin ‘falling’ further as scaled down, then clipping into ground as scaled up: move pivot point to bottom.

End result via gifcap.dev :wink:
Recording 2024-08-07 at 06.04.03

So definitely both working together, but “some fudging required”.

Having done said test now, and despite getting it to work, I can only double down on the no physics suggestion.

Fake it.

My ultimate goal is not only to have them shrink into your body, but also chase you (e.g. if you run past the coin which triggers the pickup, the coin should ALSO kind of chase you a bit faster to meet up with your running body).

I would VInterp this, record coins starting pos on pickup start, then (using the 0.0 → 1.0 ‘pickup progress’) each frame VInterp from the starting point to the characters current position (plus on offset, or use a particular bone/socket/whatever). If this is too linear, put the progress through a curve first to fake the speeding up (or just cube it maybe).

The bounce you get from physics is nice, but you should be able to fake that easily enough. Another option (which I don’t like for some reason) might be to use physics on the drop, and when it comes to rest disable.

1 Like