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"

Adjusting Projectile Velocity with LMB Hold

Hi all,

So I am working on tweaking the blueprints from the marketplace item Generic Shooter to fit my current needs, which involve holding down the left mouse button to "charge" the projectile and increase the velocity or just the initial speed of the projectile. (it's for a bow)

Currently when I fire it seems to only be taking the default speed/velocity and the projectile is simply dropping to the floor. The Fire (LMB) event is in the player character's blueprints, and after some toying around with that and the projectile blueprints, this is what I have come up with.

The idea with this version is that it counts how long the mouse button is held down, then it should multiply the amount of seconds by 500 and make that the initial speed for the projectile.

Player Character BP

alt

Projectile BP

alt

I'm not quite as experienced with this engine as I'd like to be so I assume I have made a few errors in here, so any guidance would be much appreciated. Apologies if the links are a bit messy and hard to follow in the first image.

Product Version: UE 4.14
Tags:
more ▼

asked Feb 16 '17 at 11:39 AM in Blueprint Scripting

avatar image

MohawkMark
1 1 2

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

2 answers: sort voted first

i think this should work, but actually i suggest you to set the initial velocity instead of the max, since it's an arrow it should start fast and fall instead getting faster while it's in the air (like a missile), i also suggest you to avoid using tick, in this case this should not be a problem but using tick may cause you to have a heavy CPU load. try the same code, but change the "initial speed" instead of the max speed and try to set the speed in the projectile's "event begin play"(so it will be set when the projectile spawn)

more ▼

answered Feb 16 '17 at 12:49 PM

avatar image

veccher
1.1k 31 17 66

avatar image MohawkMark Feb 16 '17 at 01:14 PM

Thanks Veccher,

I'll take your advice on this when I get back from work today, as everything I see looks pretty much spot on, but the max speed is a variable name, I am changing the initial speed :)

Event Begin Play will be my first port of call, but can you see any reason as to why this isn't changing the initial speed at all?

avatar image veccher Feb 16 '17 at 01:38 PM

oh yah, just noticed you're actually settings the initial speed, tried to replicate at my end, tried to change the initial speed at begin play and it had no effect, i have a theory, i think the "initial speed" variable in the projectile movement component is used just to apply the initial velocity but after this use the variable has no use at all, you can change it, but changing the variable won't change the speed, my theory seems to be enforced by the fact that if you try to change the initial speed in the construction script (while the actor is being created) it actually works, but the problem for you is that you can't get a reference to the player character from the construction script, i will try to find a workadound for you.

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

I would do this in a slighlt different manner. Instead of a tick, use function. Wiht LMB pressed use "set function timer by name" node - check looping and adjust the "tick" of the function. The function itself is really simple, just set velocity by multiplying previous value by 1.05 or something lower. On LMB released just pause the function.

more ▼

answered Feb 16 '17 at 01:50 PM

avatar image

andrzejBG
100 7 8 14

(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