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"

How can I control the animation in sync with the rate of fire of a turret (SkeletalMesh)

Hello,

I have created a turret which shoots at my enemies. The Turret is a Blueprint which consists of a skeletal mesh which has an animation blueprint connected. In its animation BP I have created a state machine:

alt text

if isShooting is true, it proceeds to the 'shoot' state.

In my Turret Blueprint the "shoot logic" looks like follow:

alt text

What my turret now does is that it constantly plays my animation and spawns infinite bullets, so it is out of sync.

alt text

So the problem is that I need to add something like a rate of fire. But how would I achieve that with an animation Blueprint ? I have tried to use animation notifiers but they seem to have a bit of a delay ?!

Product Version: UE 4.13
Tags:
statemachine.jpg (58.2 kB)
turretblueprint.jpg (177.0 kB)
turret.gif (1.4 MB)
more ▼

asked Sep 21 '16 at 02:31 PM in Blueprint Scripting

avatar image

LifeArtist
47 8 13 18

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

1 answer: sort voted first

Necro ... but anyway.

RoF is simply a delay between shots. 60 / RPM will return the delay value as a float.

Spawn projectile, Set Timer, Play montage. The montage play rate may need to be sped up to sync. So Take the duration of the montage and divide it by the delay.

700 RPM (0.0857 delay). Say the montage has a 0.233 duration. 0.233 / 0.0857 = 2.718786464410735

Set the Play rate of the montage to 2.7.

You will need to setup additional logic to ensure the RoF isn't bypassed. A common approach is to set a bool "Is Shooting" to true before you spawn the projectile. Then setup an Anim_Notify at the end of your montage to execute an event which sets the bool to false (so next shot can be fired). The downside to syncing to an animation is you're making ROF framerate dependent.

Animations have frame time. Each frame must be processed. At 60FPS the frametime is 16.67ms, At 30FPS it's 33.33ms. So this means regardless the RoF (0.086 as in example) the animation needs 7 frames to process before the anim_notify can be triggered .. thus 116.69ms delay.

If you decouple the montage from handling the bool reset. you can keep framerate independence.

Bool true -> delay (0.086) -> bool false

The downside to this is on low fps you can have multiple shots fired in a single animation cycle (multiple per frame). Similar to your turret. Meaning the animation might look like only one projectile was spawned, but in reality there where multiple.

more ▼

answered Jan 24 '19 at 11:03 PM

avatar image

Rev0verDrive
1 1 1

(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