#how to check if the arrow is on top of the red gui part?
1 messages · Page 1 of 1 (latest)
depends on how you are rotating the arrow, if you have the center point middle and just rotating that then I would set up so that you grab the position of the rotation of the circle, and setup like a upper and lower bound that fits the degrees the red part takes up
so like if the red part is centered at the top, that would be 0 degrees, so you check whether the arrow is rotated -90 to 90 degrees
if that makes sense
so you want me to figure out which angle range the red part takes up
yes, then when the player presses space, check if the arrow is within that range
this required the arrow and red area to be synced, to where the same angle points in the same direction
or just calculate the offset and add that in
I can get the center point I am already am using it in my code but how do I use it to get the angle range you're talking about
are you rotating the arrow from the center point?
if so you can just use the rotation property
I am changing the rotation and position of the arrow
hmm, if possible I would change it, to where the arrow is at the top of the image and the center is blank, so you can line up the arrow to the circle, and just rotate that
instead of worrying about position
im bad at explaining things ill see if I can find a reference
If I just change the rotation of the arrow then it will just spin around itself
instead of this
do this
red dot is center for both
the second method allows you to rotate the arrow while updating its position aswell so it stays in a circle
you just have to center the image to the center of the circle, and resize it to the arrow is in the right spot
but this is an example of angle 0 @west cloud
angle 180 would be directly opposite, etc
I am having trouble understanding what you mean, you want the arrow and the circle to have the same center?
yes
but that would look dookey as hell
how come? it should look the exact same, but instead of updating the position and rotation of the arrow you are just doing the rotation
but lowkey I just realized you might not need to, cause you are still rotating the arrow image, so just use that
the rotation thing just makes it point at the center it doesn't change the position
yes, we can still use the rotation to find out the position of the arrow
ex: if the arrow is pointing left, the position must be on the right, 90 ish degrees
arrow is pointing up, the position is at the bottom, 180 ish degrees
then you can compare that to the range of the red target area
so we're basically converting rotation into position
kinda
so I gotta figure out how much the position changes relative to rotation
Not really, we are just trying to find out if the rotation of the arrow is within 90 degrees of the rotation of the circle
assuming you are setting the rotation of the circle to get its different target area positions
why 90? are you assuming the red part takes up quarter of the circle?
yes
well idrk if it's exactly quarter
thats just what it looked like, you will have to figure that out tho lol
that looks like a quarter lowkey, might be ever so slightly less
but make sure both the circle and arrow is rotated to be synced, will prob make your life easier
so basically if arrow.Rotation - circle.Rotation <= 90 right?
I would do
arrow.Rotation - circle.Rotation + 45 <= 90
im pretty sure you can go negative with this, life if arrow is at 90 and circle is at 130
we are looking for -45 to +45, so we can add 45 to the value to get it within the range of 0 - 90
just do an extra check to see if its below 0
ok so after a basic experiment using print(arrow.Rotation, circle.Rotation) I found that the arrow and the red part are somewhere in the 0 to -90 range
oh, then i guess just check for that then
so basically arrow.Rotation - circle.Rotation >= -90
as long as the number cant go above 0 then yes
so okay I am getting inconsistent behavior sometimes it counts it on the red part and sometimes it doesn't lemme do print again
oh
lemme use modulus ig
because roblox does angles in the 180 to -180 range
oof
k
as you can see I was completely missing the target on purpose and it still counted
can you show me what the console looks like when a incorrect action occurs, and print both the arrow and circle rotation alongside it + what the final rotation looks like when you subtract then together
also here's the final product js incase it wasn't clear:
(arrow.Rotation - circle.Rotation) % -180
are both the rotations synced, like 0 degrees for the arrow and circle are right on top of each other
the arrow's rotation begins at 0 and the circle also begins at 0 if that's what ur asking
when they are both 0 does the arrow perfectly overlap the target in the middle
or when they share the same rotation value in general
nope
when both are at 0:
that could be it, at least its def a problem, because if both rotations are the exact same, then it would visually look incorrect, when our math states otherwise
either try to find the difference in rotations and include in the calculation or manually rotate the circle png to be at the top
like the png itself
I could make the arrow hit the middle of the red part the recalculate the range using print
rotation is 69 lol:
so add 69 to the circle rotation maybe
yeah still off.
lemme do print again
rip
I think the modulus I added messed it up, it's probably that I got the range wrong I have to be like on point
interesting, thats probably a sign of progress tho
ok yeah works for the most part any issues are probably due to the range being slightly off, anyway thanks for the help @inner oracle