Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Thread Tools Display Modes
If 'object' is over...?
Posts: n/a
Default If 'object' is over...? - 12-15-2009, 10:58 AM

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,

Reply With Quote
Super Moderator
x2495iiii's Avatar
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 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.

Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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