Man with a gun problem,

Just started using Construct 2? Post your questions here

Post » Mon Mar 07, 2016 12:05 pm

Hey, So I don't usually post as I can normally find what I need,,

I've made a placeholder man, (just a rectangle) and I've attached an arm (Just a smaller rectangle), I've done the every tick set position blah blah, that works.. I've also told it to set the angle towards mouse.x mouse.y,.. everything works.. I just need to restrict the angle so my arm doesn't do a 360 all the way around... I have searched a fair bit but i'm probably missing it because i feel this would be a common thing?..

Can somebody either direct me to a thread for this or rapid fire the answer below please..

Thanks In Advance..

Ste,
B
13
S
2
Posts: 53
Reputation: 855

Post » Mon Mar 07, 2016 1:07 pm

It's not exactly a degree thing, but for e.g. platformers this would work nicely

You would need to make another condition to your set angle mouse event

you could make an invisible object and add condition if NOT over invObeject > follow mouse
or even better
system > compare values
first = Mouse.Y
<
second = 400 (so only follow if not greater then Y 400)
same for Mouse.X and you are done

edit: changed some typo
Last edited by fm4fanAT on Mon Mar 07, 2016 1:54 pm, edited 1 time in total.

  • System > On start of layout | system > load game from slot "brain"
  • System > On load failed | system > scroll to obj_Forum
B
17
S
8
G
5
Posts: 340
Reputation: 4,707

Post » Mon Mar 07, 2016 1:43 pm

Hi that's brilliant, The compare variables work, just so I can now tweak it to suit exactly what I need, what does the 400 represent? Like when my mouse is a certain distance away it doesn't follow, Is 400, 400pixels?

Sorry quite new.

Thanks..
B
13
S
2
Posts: 53
Reputation: 855

Post » Mon Mar 07, 2016 1:46 pm

The X and Y coordinates start on the top left corner with 0,0
So if your game is 1280px by 720px the right bottom corner would be 1280, 720

If you want a mouse movement only occur on the top half you just take 360 (720/2).
So the 400 only represent some random Y value I took - so the mouse only follows if the mouse is maximum 400 away from the top.

To stop mouse movement if your cursor is off screen you can add another event like
if smaller then windowWidht (or WindowHight depending if X or Y)
and greater then 0

  • System > On start of layout | system > load game from slot "brain"
  • System > On load failed | system > scroll to obj_Forum
B
17
S
8
G
5
Posts: 340
Reputation: 4,707

Post » Mon Mar 07, 2016 3:33 pm

This is excellent! Thank you very much :D, So top left is ground zero, good to know!! :), I hope you'll be happy to know you've solved about 4 or 5 problems today :P,

Help was much appreciated. Thanks
B
13
S
2
Posts: 53
Reputation: 855


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest