This is a problem that most of you guys have figured out but I haven’t. How do you attach a thing to another thing? I am trying to attach a Tetris Line with a Circle to make a tank turret. I can’t seem to make the Tetris Line also rotate when the circle is rotating and still have them both attached.
hey, to do this, you should use a little bit of trigonometry
Tetris:
Set SelfX to cos(Circle’s Angle) * Distance to Circle + X position of Circle
Set SelfY to sin(Circle’s Angle) * Distance to Circle + Y position of Circle
Hope this helps! Tag me for any other questions.
Welcome to the forum, by the way! :))
yeah, welcome to the forum!
Welcome to the forum!
Yeah I think that’s how it works
Welcome to the HS forum!
You can find the “self x” and “self y” in “objects”
How do I change the code to the blocks on the Hopscotch app. I can’t seem to find SelfX or SelfY anywhere. Thanks! (I am a newbie)
yup ^^^
to keep the tetris line pointing at the turret, add this code
When SelfX < CircleX
Set Angle to arctan((SelfY-CircleY)/(SelfX-CircleX))+180
End
When SelfX > CircleX
Set Angle to arctan((SelfY-CircleY)/(SelfX-CircleX))
End
check this link ^^^ for full code - this is using @/Awesome_E project builder so it will not open in Hopscotch
The code doesn’t seem to quite work. Can you guys check my code to find any errors?
^^^This is the problem.
I have published my project so I think you guys can see the code(look in the Tetris Line). Thanks!
can you send a link? i can’t seem to find your project
I tried to fix it, but I’m not sure how to make the gu.n stay since the angle makes the position look weird.
This topic was automatically closed after 3 days. New replies are no longer allowed.