limiting rotation?

For questions about using Classic.

Post » Thu Apr 24, 2008 6:27 pm

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.


The guy to the right doesn't hit himself.


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:

And here's the cap if anyone needs it: http://www.mediafire.com/?tt4u2y2nwz7
B
3
G
4
Posts: 28
Reputation: 1,133

Post » Thu Apr 24, 2008 6:38 pm

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
B
3
S
2
G
4
Posts: 310
Reputation: 2,120

Post » Thu Apr 24, 2008 6:44 pm

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.
B
3
G
4
Posts: 28
Reputation: 1,133

Post » Thu Apr 24, 2008 6:54 pm

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.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Thu Apr 24, 2008 6:55 pm

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.
B
2
S
2
G
5
Posts: 448
Reputation: 2,546

Post » Thu Apr 24, 2008 7:08 pm

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.
B
3
S
2
G
4
Posts: 310
Reputation: 2,120

Post » Thu Apr 24, 2008 7:21 pm

[quote="CaptainOblivious":3d2wa3zv] 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.[/quote:3d2wa3zv]

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.

[quote="deadeye":3d2wa3zv]Or rather, "myLowLimit" and "myHighLimit"[/quote:3d2wa3zv]

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.
B
3
G
4
Posts: 28
Reputation: 1,133

Post » Thu Apr 24, 2008 8:57 pm

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 :(
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Thu Apr 24, 2008 9:49 pm

[quote="deadeye":3rmck3cj] I tried doing it with math but I really suck at math.[/quote:3rmck3cj]
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!
B
3
G
4
Posts: 28
Reputation: 1,133

Post » Thu Apr 24, 2008 9:53 pm

Isn't there a way to calculate the angle as normal, but flip the sprite graphically after the calculation?
B
2
S
2
G
5
Posts: 512
Reputation: 2,674

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest