I’ve been having a lot of trouble controlling “Projectile Direction” for a (3d) 2d movement Side-Scroll game, unfortunately only a few tutorials address this issue (especially regarding 2d projects)
I have a basic code for my character to fire a projectile.
I can control the “Direction” the projectile fires - in the “Velocity” settings in the projectile’s movement component. {Thanks to Mopper!}
But I can only shoot in one direction - right now it fires to the right, but if I move character left - the projectile still fires right. My 1st GOAL: is to get the projectile to fire in the direction my character is facing, either left or right - that would be a great start.
(Not sure if I’m correct with this, but I have these axis inputs set up to a single button press “V”)
[Fire Right] scale value of 1
[Fire Left] scale value of -1
Ideally the main GOAL: is to fire in all directions 360 degrees! I’m hoping someone has a code or something that can make this happen. Any help, suggestions, advice or explanations in regard to these issues would be greatly appreciated as resources for 2d projects are somewhat limited. Thanks!
Direction of a projectile is dealt with by the Projectile movement component, there you can restrict planes and set the initial direction travelled… some screenshots of your projectile Blueprints would be helpful
Thanks for taking some time to respond man… attached is a screen shot of my basic shooter code. Just to mention again, I have two mirrored projects and the code behaves differently in each one. ( *curious to get your opinion on that…)
I found the restrict planes you referred to in my projectile movement component, and I understand the basic Plane Constraint Axis Settings options.
But I don’t exactly understand when you say, “set the initial direction traveled”.
Any chance you can breakdown the difference between Plane Constraint Normal and Plane Constraint Origin??
I tried experimenting with them, but could not get a controllable result.
Thanks again, really appreciate all your feedback…
Keeping in mind the first XYZ is worldspace, the other 2 are localspace!
Are the projects literally copied or did you merge parts?.
your control rotation basically determines the projectiles rotation wich isnt good it can cause it to fire in a different direction than you expect
Velocity tab is the direction your projectile goes in when spawned with the Initalspeed variable, thats what i meant with initial direction
Keep in mind this is the LOCAL space of the projectile so the X Direction it was spawned with is the direction it will fly in.
the constraint works as follows:
constraint Normal = thats the axis it can move in
constraint origin = say for some reason it is spawned at y = 100, if you have snap to plane at start checked it will automatically move it to y = 0 or whatever you have in constrain origin for that axis.
I believe these are WORLD space (someone correct me if im wrong i didnt do all that much with 2D Projectiles)
So you need to be aware of all your Directions for each blueprint and make sure your projectiles X axis (default movement direction) is aligned with wherever you want it to go.
Thanks again - your were extremely thorough and helpful with your answer, but it took me some time to wrap my mind around it.
[To answer your question, my projects were built together simultaneously - side by side. Whatever I did in one project I did in the other and tried to mirror two exact projects.]
Now (thanks to you) I’m able to control the projectile direction via “Velocity” in the projectile movement component. Awesome!!
I think I understand when you say “you need to be aware of all your Directions for each blueprint and make sure your projectiles X axis (default movement direction) is aligned with wherever you want it to go”
This is what you circled in your screenshots. I see how your map, character BP, and projectile BP …all are in alignment.
I guess my confusion is this… when you start a new default side scroll project template (I’m using the “regular Side Scroll Template” - which is actually a 3d side scroller, …the default values are set to Y= is left and right and Z= is up and down. The X axis represents “depth” or the plane in which you would want to constrain. {I attached a screen shot}
Unclear how to align the map, character BP, and projectile BP’s given these template defaults.
Also, I can only shoot in one direction (right) even though “axis inputs” are set up for both right and left
[fire right=scale value1 \ fire left=scale value -1]
I’d really like to have it like Contra, where the player can fire in all directions 360 degrees…
None the less, can’t thank you enough for your time & thorough explanations!!
Mind if I ask how long you’ve been working with UE4??
As always, your feedback is much appreciated!!