Change Scale of Projectile over Time?

Hi all,

I wonder if anyone can help me with this.

I am currently using the Projectile Movement component to fire my projectiles off into the world. Basic functionality is working as expected, press fire, projectile spawned, off it flies - great.

I would now like to affect the scale of the project after it has been spawned, as its moving away. The projectile is supposed to be a “bubble”, so I wanted it to start small, then gradually grow, then disappear - as if it had popped.

I’ve set the actor life span to 3 seconds, so the “popping” part is kinda covered. I’ve had a go at increasing the scale today and had some weird results that I can’t quite understand.

I’ve added a timeline and set its length to 3 seconds, in line with the duration of the life span of the actor (not entirely happy these are separate values but will worry about that later).

In the graph, although you can’t see them, there is a curve for each axis, X,Y,Z, all with a value of 1 for 0 seconds, and ending with a value of 3 at 3 seconds.

The projectile’s static mesh has an original scale of 0.25, so I assumed multiplying the value from the timeline by its existing scale would create a gradual increase in size.

I think that part might be working, but there is a very strange behaviour being exhibited where-by the projectile fires out and then seemingly returns back to the player pawn?

Without the scaling, this is the original behaviour, as you can see, the projectiles carry on moving much further and do not return to sender

I would really appreciate any help with this if anyone can spare me a little time.

Thanks in advance for your consideration :slight_smile:

Hi Rob, you problem is you’re sampling the projectile scale DURING the timeline. So the changes you’re making are like compound intrest, the projectile is ballooning beyond belief.

It will work much better if you put the current scale in a variable ( vector ), set the final intended scale, also in a variable, then use the timeline to lerp between those two values. Then you can just have a simple 0-1 in the TL, much easier :slight_smile:

Hey @ClockworkOcean, thanks for the swift reply, appreciated.

I’ve fiddled a bit since posting… I removed the scale nodes and just output via print node. The values for X,Y,Z from the timeline were all perfect, 1.0 all the way to 3.0 for each axis. When I then added the multiply node back in, I got the expected values also, they all ended up on 0.75. When I messed around a little more and set the actor scale instead of the static mesh scale, I got a very large sphere and a lot of errors about invalid scale values, which, whilst reading your reply and thinking about it, makes a lot of sense.

I still don’t understand why the projectile returns-to-sender though… its as if the scaling is screwing up the Projectile Movement component, of which I don’t have a lot of control.

Regarding your suggestion, very happy to give that a go, fairly new to timelines though. Would I use a Float Track for that, e.g. the 0-1 part? How do I plug in the initial and final vector variables, I dont see options for that? Is that outside of the timeline in the normal graph editor?

Thanks again for the reply :slight_smile:

I tried this;

I entered values of 1.0 for the start scale, and 3.0 for the end scale.

When run, the sphere’s just appeared big. I then figured I’d need to multiply that back to the current scale of the projectile. I was then back in exactly the same problem as before. So removed the multiplication stuff back out, realising the repeated mistake.

I set the values to the “actual” scales I wanted, 0.25 and 0.75 - I’m not personally keen on that as its very hard-coded, but in order to get something working etc… ran it, no noticeable change. Projectiles did continue to fly into the distance though which was good.

I then edge-case tested it, setting the end scale to 5. Now, you can see the timeline is affecting the scale, you can see the projectile grow - however…

The 3 seconds configured in the “Length” for the timeline appears to occur way before the 3 second life time duration for the actor, e.g. you fire a projectile, it grows very quickly (far quicker than 3 seconds), it hovers around a bit at full size, then gets destroyed.

I am also back to a position where the scale projectile is having an impact on how far it travels, it looks like the scale of the projectile does affect the Projectile Movement component.

Thoughts very much welcomed.

It’s not returning. It’s just getting so big it looks like that. Gimme 5 I’ll post a bit of code…

Ah, ok… weird effect…

I think we overlapped btw… I just updated my original reply above, with what I’ve tried…

I have ramped up the projectile initial/max speed from 1000 to 2000 and I’m getting closer to the result I’d like, but I think the biggest issue right now is the timings, e.g. the 3 seconds on the timeline and the 3 seconds life time for the actor seem to not be happening at the same time… the effect is that you fire a projectile, it flies out, grows to max size, then seems to continue on moving afterwards, until eventually being destroyed… I want the projectile to be destroyed when it gets to full size, had assumed having these values set the same would have achieve that… very weird. Might have to stop the player pawn movement to test this as it may be creating some “illusionary” effects…

Code is like this:

Results:

expand.gif

PS: It’s almost impossible to upload a GIF here, answer hub is a much better resource if you want help :wink:

See my stuff below, well, above, now…

Thanks so much for taking the time to reply and help me with this, very much appreciated.

Looks like after your initial suggestion I wasn’t too far out with what I cobbled together. I’ve updated it since to use the Actor Scale rather than just the static mesh, that should resolve any subsequent issues with the collision detection (being too small).

I’ll check out answer hub also… is that effectively a replacement for this forum?

The forum is for discussion, answerhub is for answers, hence the name :wink:

You will tend to get meadering diatribes on the forum, whereas on AH, people get ‘karma points’ when you mark a question as answered. So the drive to give you a correct answer is much greater…

Also, on AH, you don’t have to remember to keep quoting / liking people. The notifciation is handled automatically.

LOL… that’s actually the first time today I have laughed, thanks for that! :smiley: :stuck_out_tongue:

Well thank you again for answering my, non-incentivized, question here - very much appreciated and I’ll send some virtual good karma your way :slight_smile:

That’s a definitely bonus… ok, I’m sold, I will check it out for my next question… :slight_smile: