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

2017/1/26

activating a command when an actor hits a certain side of another actor

ruvdog25808 ruvdog25808

2017/1/26

#
Hi. So I want to make it so that when my laser hits a reflector, it bounces of it in the direction the reflector is facing. I already have it set up to when the laser hits a reflector, it bounces of it. However, I want to make it so that (since the reflectors are slanted) the shot only bounces of the reflector from one particular side. For example, if a shot bounces of a reflector like this (the reflector is / and the laser is <--). I want it to be so that if a shot hits like this -->/ it changes the lasers direction to up and if it hits like this /<-- it changes direction to down. And the same for left and right. if u need further elaboration i can provide.
ruvdog25808 ruvdog25808

2017/1/26

#
is there a way i can use a get width and length command or something
danpost danpost

2017/1/26

#
ruvdog25808 wrote...
is there a way i can use a get width and length command or something
Maybe the 'getRotation' method could be useful here; that, together with the current direction of the laser should be enough to determine the new direction for the laser to proceed.
ruvdog25808 ruvdog25808

2017/1/26

#
i thought so do u have any ideas for a code that could check what side the laser hits.
danpost danpost

2017/1/26

#
ruvdog25808 wrote...
i thought so do u have any ideas for a code that could check what side the laser hits.
It does not matter which side. The reflective angle is always twice the angle of the surface minus the angle of incidence.
ruvdog25808 ruvdog25808

2017/1/26

#
oh ok thanks i think i understand
danpost danpost

2017/1/27

#
ruvdog25808 wrote...
Hi. So I want to make it so that when my laser hits a reflector, it bounces of it in the direction the reflector is facing
How are your reflectors working out? and your beams?
You need to login to post a reply.