This site requires JavaScript, please enable it in your browser!
Greenfoot back
AbdulrazaqAS
AbdulrazaqAS wrote ...

2022/7/14

Check an offset relative to my rotation

AbdulrazaqAS AbdulrazaqAS

2022/7/14

#
Hello, I want to always check what is in front of my actor before moving but i dont know how i will use the method getOneObjectAtOffset(int dx, int dy, Class<?> cls) or any other method to achieve that. The main problem is the parameters of the method, because i will have to use change the dx and dy for every change in my rotation and it seems not easy. Pls how can i call the method with the parameters automatically changed with change in my rotation.
danpost danpost

2022/7/14

#
AbdulrazaqAS wrote...
Hello, I want to always check what is in front of my actor before moving but i dont know how i will use the method getOneObjectAtOffset(int dx, int dy, Class<?> cls) or any other method to achieve that.
Use sine and cosine of rotation multipled by distance. Rotation will need to be converted to radians.
AbdulrazaqAS AbdulrazaqAS

2022/7/16

#
danpost wrote...
AbdulrazaqAS wrote...
Hello, I want to always check what is in front of my actor before moving but i dont know how i will use the method getOneObjectAtOffset(int dx, int dy, Class<?> cls) or any other method to achieve that.
Use sine and cosine of rotation multipled by distance. Rotation will need to be converted to radians.
Thanks, it worked.
You need to login to post a reply.