How would I Set the Offset of Sprites Origin?

Get help using Construct 2

Post » Tue May 30, 2017 10:52 pm

Hey guys!
I'm evidently new here, and I look forward to growing within this community! So far I love what this program has got to offer to indie developers of all programming experiences. My programming skills tbh [3/10] 10 best.

Anyways, I'm trying to get my players Torso to pivot from hips on Legs obj., which I can do successfully. Where things go wrong is when the angle of Torsos to Mouse.X/Y. Since ImagePoint 1 is set to barrel of gun, and image angle is based off Torso Origin to mouse.X/Y instead of gun barrel to mouse.X/Y , there's always that odd angle of trajectory from bullet to mouse coordinates which causes bullet to go over or under mouse.

What method(s) can I go about to have gun barrel precisely lock onto my mouse coordinates? That way, when I move the mouse, barrel is always aligned/leveled with mouse (along with torso, as it's a part of the same object), AND have bullet fire from barrel right into my mouse as any shooter would like. :)
*I still want Torso to pivot from hips!*

Mucho Thanks!
B
4
S
1
Posts: 3
Reputation: 306

Post » Wed May 31, 2017 2:47 pm

Would this work for you? I've split the arm into a separate sprite to the torso, which allows more accurate aiming - you can restrict the arm movement range to that of the torso if you want them to look fixed together.

https://www.dropbox.com/s/c35i4hamv9xnz ... .capx?dl=0
B
19
S
8
G
3
Posts: 432
Reputation: 3,978

Post » Wed May 31, 2017 8:50 pm

Sir 'mekonbekon', that was marvelous! Thank you
Just so I could gradually become less dependent on others help, I'm trying to understand what you did there but it's honestly confusing.
Like the order of x1,y1, x2,y2 (the mouse. and self. order), and the two degrees. How would one know if it's necessary or which degree slot does what? Experimenting? Sheesh!

Okay, now if I required more precision on barrel-to-mouse...wouldn't I need to create an offset? ORRR, I could align by drawing, shoulder/barrel exit at same height starting at 0 deg. so it's as if it's taking coordinates from barrel. The con about that is inaccuracy at long distances which my game will have.
An idea... would it be a good one if we could have have projectiles travel at a slightly altered angles after mouse is > than specified distance and Y pos/height? and vice versa with < (because fyi, projectiles at longer distances that are not 100% aligned will have gap on south of mouse or north of it depending on Y pos/height. More noticeable with greater distances.)
B
4
S
1
Posts: 3
Reputation: 306

Post » Wed May 31, 2017 10:06 pm

Yeah I had to do quite a bit of experimenting myself to work out the correct order and angles - try fiddling around with the two angles to see how it affects the limits of the torso position.

As you suggest, you could also adjust the angle of the bullet at the point of creation based upon the mouse position - you're going to be pointing in approximately the right direction anyhow, so if you set the bullet's angle using a similar scheme to this to ensure it's range of angles was limited you could get pinpoint accuracy. If I get a chance tomorrow I'll see if I can knock something up, and add some comments to the original demo to explain the code.

P.S. - I got a bit carried away with this demo and came up with this: http://bats00.bitballoon.com :)
B
19
S
8
G
3
Posts: 432
Reputation: 3,978

Post » Thu Jun 01, 2017 1:27 am

Dude, I'm very grateful for your help, especially on this project that means alot to me.
:O Lol the game is kinda fun. It's a nice one for being made spontaneously. Okay I look forward to it although it's really not necessary.
B
4
S
1
Posts: 3
Reputation: 306


Return to How do I....?

Who is online

Users browsing this forum: sean080, Yahoo [Bot] and 20 guests