Made this little cart as I was working through coding a look-at type function. Wanted to post it in case it's helpful for someone.
This type of functionality is useful for all sorts of things. Maybe you just want one character to look at another or a gun barrel to follow the cursor etc.
Strangely last night I was thinking of the Apple ][ game called "RobotWar."
What's especially interesting about this game outside you have the ability to write code for your robot to battle other robots is its unique ability to SEE other robots.
And I don't just mean diagonally or from a cross +, no, you could rotate the head of your robot and if you were within range of both your sensors and angle, you could indeed see your opponent and react thusly.
Just me guessing the easiest way to do this would be for the computer to determine the angle to the other target and then get an ABS() for the angle of the "head" of the first target (player) and get a number from 15 or less so even if its not in perfect sight, it can vary a bit.
Also to check distance. Too far and the robot cannot see the opponent.
What would especially be interesting, PL, would be to add walls, both horizontal and vertical, and be able to be blocked by attempting to look through this solid object.
[Please log in to post a comment]