|
|
|
|
|
|
|
|
Senior Member
Status: Offline
Posts: 442
Join Date: Feb 2011
|
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.
|
|
|
|
|
Senior Member
Status: Offline
Posts: 1,112
Join Date: Mar 2011
Location: I don't know
|
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
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.
|
|
|
|
|
Super Moderator
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
|
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.
|
|
|
|
|
Senior Member
Status: Offline
Posts: 442
Join Date: Feb 2011
|
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.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.
|
|