limiting rotation?

This forum is currently in read-only mode.
  • I ran into a problem and can't see a solution, maybe some fresh eyes will solve it?

    I have made an example:

    Two green guys each have a red stick, they always try to aim this stick at the ball, but they shouldn't hit themselves with the stick. I figured out how do this with the guy on the right, but not the guy on the left.

    <img src="http://farm3.static.flickr.com/2057/2439350474_89dd2a1103.jpg?v=0">

    The guy to the right doesn't hit himself.

    <img src="http://farm3.static.flickr.com/2298/2438525823_203eb8cd74.jpg?v=0">

    The guy on the left side just poked his eye out.

    The sticks simply rotate after the ball, but the guy on the right side has a

    +stick angle greater than 265 - Set angle to 265 that keeps him from hitting himself, the guy on the left side on the other hand can't do that since his stick is on the side of the circle that has both 0 and 360. Any good ideas? I'm sure there's something obvious I'm missing.

    Here's the event sheet:<img src="http://farm4.static.flickr.com/3225/2438525777_ea4021480c.jpg?v=0">

    And here's the cap if anyone needs it: http://www.mediafire.com/?tt4u2y2nwz7

  • The easiest solution is to use two different sticks, and adjust your rotation limits per each one. A better solution would be to control right or left side actions by a private variable. Stick.Side == "Right," limit rotation blah blah blah

  • whoops, forgot to mention that they have a private variable like that called "side". My problem is figuring out the way to limit the rotation for left guy's stick. It can't use the same rotation limiting event as the guy on the right. since "+stick angle greater than 85 - Set angle to 85" would also include the angles from 270-360.

  • Try giving each of your sticks a "myLimit" variable, then build your rotation limiting event calling on each stick's variable rather than a fixed value.

    Edit:

    Or rather, "myLowLimit" and "myHighLimit"

    Or whatever.

  • you have to somehow let construct know which stick belongs to which guy, obv the easiest way it to make 2 different sticks. But you could also set a variable like 1 being left guys and 2 being the right guys stick. Then set limits on rotation based on who it belongs to.

    EDIT - Just reilised... You can just say "always + as long as stick is not overlapping man" = Stick look at ball. Simple.

  • Alee, that would be great if the guys weren't holding their sticks. Overlap commands here would stop the movement altogether. I haven't tried this, but you could use the overlap way if you did it by image point instead of the object's collision box.

  • I haven't tried this, but you could use the overlap way if you did it by image point instead of the object's collision box.

    That might work, but I prefer not to since I'm later going to add more sticks of different sizes, so a stick with a greater width and height would trigger an overlapping event at a lower angle than a smaller stick.

    Or rather, "myLowLimit" and "myHighLimit"

    I'll try to see if I can do it this way.

    EDIT: uhh.. Deadeye could you explain a little more how your solution works? I didn't quite get how to set it up.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Oops, just ignore what I said earlier. Now that I've played around with it a bit it's not as easy as all that. I tried doing it with math but I really suck at math. It seems the easiest way would be to make completely separate rotating events for each side. Sorry

  • I tried doing it with math but I really suck at math.

    This seems to be contagious, I suffer from it as well.

    This one is really frustrating since the right side can be done so easily with "Angle greater than", and "Angle less than" conditions since it all happens in the 90-180-270 angle range, but on he left side they don't work since it happens in the 270-0-90 angle range, and therefore it seems like conditions like "Angle less than" and "Angle greater than" are useless. If anyone knows a solution please let me know!

  • Isn't there a way to calculate the angle as normal, but flip the sprite graphically after the calculation?

  • Just checked out this thread and I think you guys missed out on a nice simple solution. Math FTW! I threw in a text object and set it to the left stick's angle. The solution was much easier to figure out when you can see the angles it needs to bound to.

  • Ashley saves the day!

    You forgot the text object though, so I put one in myself, but one thing I don't get is why does the text object show the angle as 270 when the debugger shows it as 275?

  • I'm not sure, but I'd guess the exact time the debugger checks what the angle is, and the exact time your events change the angle, are slightly different. Nothing serious though.

  • Doh! That is way simple. I guess that's what I get for reading Help/Tech before I've even had my morning coffee.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)