Alice Community  

Go Back   Alice Community > General Discussion > The Lounge

Reply
 
Thread Tools Display Modes
Let's derive shooting with crosshairs.
Old
Mr Kidnapper
Senior Member
 
Status: Offline
Posts: 442
Join Date: Feb 2011
Default Let's derive shooting with crosshairs. - 01-26-2012, 12:59 AM

There are a number of ways to fake a bullet shooting in the direction of the crosshairs. Back in the day, Counter Strike actually spawned bullets to the sides and behind the character to fake shooting at the crosshair. Normally the user is none the wiser. At least, until you see some guy using an AUG and yellow tracers are forming behind him.
Many games, like in the previous example, simply make a muzzle flash and an invisible bullet starts flying, spawned from the point of view of the camera.

For reference's sake, how do the "Object is * direction of object" work?
Say there's a cube. If I was in an area such that I was 3 meters in front of and to the left of the cube so that I'd be relative to a corner of the cube, would it register as both "In Front of the cube" and "To the left of the cube"?
Also, if I was only in front, and not left, right, on top, or on bottom of the cube, would it only register as being in front of the cube?
This is a very important conceptual question.
Alice doesn't have "Ray Casting," or "Ray Shooting", as Wikipedia calls it. Ray shooting is a very convenient thing used to solve many spatial distance issues in video games. Crosshairs are one of them. In essence, ray shooting is an invisible, extremely long finite line that projects outward from a source. In this case, our source is the camera. The idea is that it then finds the closest object that collides with the ray. After that, you may use trigonometry to find the precise angle of adjustment so that the bullet's path is altered to hit the crosshair dead on.
If there is no closest object (You point at the sky), the bullet's path is altered to hit the end of the ray, making it seem as if you were shooting at the center of the screen. Isn't that convenient?

The problem is, as I said before, Alice doesn't have raycasting. Nor will it get any, and that is why I asked the conceptual question.
And thus I propose an assignment to the Alice Community: Design a "ray casting" substitute that will fire to the center of the crosshair from the gun. It makes no difference to me how true to ray shooting your solution is, as long as it works with any distance. You probably shouldn't ask me how to do this either. I don't know, and that's about as good an answer as you'll get.
If you excuse me, I will find a scripting solution for this that hopefully involves raycasting.
   
Reply With Quote
Old
sfunk
Senior Member
 
sfunk's Avatar
 
Status: Offline
Posts: 1,112
Join Date: Mar 2011
Location: I don't know
Default 01-26-2012, 07:16 AM

This sounds a lot like how I did the aiming with a cylinder, if I find my old post, i'll paste it here, it worked pretty well and sounds just like what you are talking about.

Well I found the old file I did this with, but I just used a cylinder and a collision detection I adapted and formed to make this work, just use A,W,S,D to move around, and if the laser touches the randomguy2, he will turn to red, and when the laser is pointed away from the randomguy2, he will revert back to his normal color.

Quick info

When I get the time i'll make a video or type out an explanation on how to do this type of aiming, or if people are interested in this they can just recreate the code from this
Attached Files
File Type: a2w newshooter.a2w (3.76 MB, 23 views)


If you are stuck on a project, check out the tutorials I made here at this link:

http://alice.org/community/showthread.php?p=36778#post36778

There are lots of tutorials on it so far, including some youtube videos, check it out

Or..

Go to my youtube channel to check out my alice 2.2 tutorials I have there..

http://www.youtube.com/user/sfunk1992?feature=mhsn

Last edited by sfunk; 01-26-2012 at 07:29 AM.
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 01-26-2012, 11:10 AM

The problem to me is the fact that there are no well-defined methods of determining the positions of the 3d models aside from using the bounding boxes, which are nice, but inaccurate if you're using tiny projectiles, like bullets.

I was actually thinking of going the Perfect Dark route and making a system that points at visible enemies for you when you get close enough.

I've also experimented with using a "distance to" comparison to determine if the target is directly in front of the character at the time of firing. It works, but it's a little inaccurate as well, in the sense that you need to account for the target's width in the formula if you don't want your users missing every time they don't hit the target dead center.

The project itself sounds very cool, but I'm not entirely sure how scripting will help us.


(')>
   
Reply With Quote
Old
Mr Kidnapper
Senior Member
 
Status: Offline
Posts: 442
Join Date: Feb 2011
Default 01-26-2012, 09:36 PM

Kind of depends on what kind of collision system you have. If you separate an animated object into boxes, spheres, and cylinders you have a pretty strong estimation of its location. If you want really good collision, you'd make an invisible collision proxy made exactly out of boxes, spheres, and cylinders.
Scripting helps by removing the requirement of a physical ray. It will be purely theoretical. If I figure out how to access the faces of models I will also be able to solve the collision problem, such as when you shoot the ground.

Last edited by Mr Kidnapper; 01-26-2012 at 09:43 PM.
   
Reply With Quote
Reply

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 ©2019, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.