Alice Community

Alice Community (
-   How do I...? (
-   -   If 'object' is over...? (

Jinkley 12-15-2009 10:58 AM

If 'object' is over...?
1 Attachment(s)
Hey all, this is my first post. Before I start, I would like to say tou guys have a tight-knit forum and I have been lurking here for awhile and usually always found the answer I need, but for this one I haven't seen anything. Okay so:

I am making (you guessed it) a first person shooter. The main screen is in my attachment below. My question is in regard to the black crosshair in the middle of the screen. I want to have the gun register as a 'hit' when the crosshair is over 'cleopatra' (for examples sake) and the 'shoot' method is ran. How would I accomplish that?

I guess how I would try to explain it additionally is that I would like to use the 'object under mouse cursor' event with something other than the mouse cursor.

Thanks for the help,


x2495iiii 12-15-2009 05:16 PM

Oooh... that's a toughie. For starters, there's no easy way to do that, but there may still be a way. You could try making a method that calculates the linear ditance between the camera and the object, and then tested to see if the intermediate object (the crosshair) was on that line (meaning that it is on the shortest path to the enemy, or turned towards the enemy). I made a somewhat similar program when I made a car slalom world which had to determine if the car went in between two orange cones. I used the distance to function to determine if the car's distance to the two cones was the same as (or very similar to) the distance between the two cones themselves, meaning it was directly in between the two cones.

All times are GMT -5. The time now is 03:24 AM.

Copyright ©2023, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.