I want to change direction of my projectile in my 2D game.
If i go under projectiles settings inside velocity and change X value to 1 it goes to right.If i change that value to -1 it goes to left.What is wrong with my blueprint and i cannot change velocity of newly spawned arrow?
It stays in whatever i have set it in properties.in my case it always goes to right.
new velocity you’re setting needs to include direction and speed. Try setting velocity in Projectile Movement component defaults to 0,0,0. Then when you set velocity in your Blueprint, set it to 1000 or -1000 (or whatever value you’re using as projectile’s speed) in X field.
Hope that helps! Let me know if that doesn’t work.
Thank you but i can not make it work.second i set to zero x velocity inside Projectile Movement component it just stays still and eventually falls off screen due to gravity.It seems that my blueprint does not set projectiles velocity during runtime even though it fires in debug mode.What am i doing wrong?
A couple of things I could suggest trying:
- In your function, you’re casting to Arrow_BP. This is technically redundant, since Spawn Actor node is already referencing it. It might not make a difference, but you can simply get Projectile Movement component (which I’m guessing you’re naming Arrow Projectile Movement inside Arrow_BP Blueprint).
- Try using Set Velocity node instead of Set Velocity in Local Space node, and see if that makes any difference. Again, set default velocity to 0,0,0 and then let your Blueprint set velocity after spawning.
- Double-check collision properties of your character and of projectile. Neither should be able to block other.
If those don’t change anything, I may need to see more images of how you have your Arrow_BP set up, including it’s component hierarchy and settings for its Projectile Movement component. I would also like to see an image of how you’re calling Archer Spawn Arrow function.
Let me know what happens with those three suggestions, and any other details you think pertinent. Thanks!
I think that i have followed your advice and i still cannot change projectiles orientation.i am posting some pictures as you requested to help you pinpoint problem.
reason i am using a timer and a fuction is because there is no currently a “on end of animation” command so i have to delay spawning of arrow at exact time archer finishes his “shoot” animation.
There is no collision between my archer and arrow since i spawn it very far away from his capsule.
It makes no difference if i use velocity or space velocity.
In picture with arrow projectile’s velocity set to 1:Here if i set everything to zero as instructed then arrow spawns and falls straight down from gravity.if i set it to -1 it flies to left and vice versa.It seems this blueprint code does not add anything to projectiles velocity second it is spawned.
Sorry for all trouble you’re having. I set up a Paper 2D project in an effort to reproduce issue you’re experiencing, but with a setup very similar to yours it works as intended. Just to make sure I’m not missing anything:
- issue you’re having is that arrow does not move in direction you want it to? Or does it not move at all?
- What version of editor are you using? I made this in 4.3 and it’s working fine, but I can check it on an older build of editor if that’s what you’re working with.
- When you set up your arrow Blueprint, are you using all these settings together:
(I used smaller values so I could see it working in editor during Play)
With it all working on my end, I don’t think I will be able to see what else might be causing this for you. If you are using 4.3 and have tried setting it up as shown in images above, I can only suggest zipping your project and putting it online somewhere I can access it so that I can look into it further. Let me know if that’s what you want to do!
Thank you much for trying to help me.
arrow does not move at all.Is there a way to P.M you my file?I have all of my assets in there so i cannot post it publicly .
You can PM me on forums. I’ll keep an eye on forum inbox for next few hours.
Okay! I looked into your project and luckily it was a real simple solution: your collision box in your arrow Blueprint is Simulating Physics. Turn this off! Simulate Physics interferes with Projectile Movement component, which has its own way of faking physics. Having both will cause all sorts of problems, as you’ve noticed. same is true of Simulate Physics and Character Movement component.
So I turned that off and it looks like it’s running perfectly with settings I described above. If you run into any new problems because you needed something from Simulate Physics, let me know and we can look into how we can fake it.
Hope that helps!
arrow projectile works like a charm!Words cannot describe how grateful i am for your time and effort!
May i ask for a small favor? Maybe you could implement a small tooltip(or some other sort of warning) that will warn us (newcomers ) when we encounter situations like this?
Not in a million years i would have thought that this would cause a conflict if it wasn’t for you!
unfortunately collision issue with turtle hasn’t been resolved!
i turned off " agent physics/enable physics interaction" in movement component in everything that has a movement component(even my main character) i checked that no trigger box has physics enabled and it still does same.
I believe that imanaged to pinpoint when collision problem starts to happen.it only starts to behave eratic second turtle touches left patrol block and has you on line of sight while you are falling from a jump.cannot understand what this has to do with collisions but i tested it 10 times and every time it meets above situation it gets stuck.could you please take another look and confirm that i am not crazy
EDIT i now believe it is time related.it starts to happen after about 20 sec regardles of where turtle is.
+1 just spent an hour or so figuring this out
+1 too. I’ve spend more then 1 hour… physic ftw
Please consider marking this as official answer.
Thanks ! Simulating physics on collision component does interfere with ProjectileMovement component. Just disable SimulatePhysics.
Faced same problem, and soooooo grateful for descision, which I found here! Thank you too!
I could not make that solution work. However, if i change max speed and initial speed at runtime under “construction script”, it works. Hope, this helps