Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Sparky's Collision Raycasting problems

Author
Message
Travis Gatlin
17
Years of Service
User Offline
Joined: 14th May 2009
Location: Oxford, Alabama
Posted: 9th May 2011 02:58
Hey, I'm having some problems with Sparky's Collision, i go to shoot the ray and it shoots it correctly, but at the wrong angle, it shoots in one direction, no matter what direction i'm facing, i know that it don't update the angle of the raycast based off of the object's angle but i want to know how i would achieve this in a first person enviroment.

My raycasting code.


WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 9th May 2011 03:16

Your raycast is using the same coords for both the start and the end.

Warning! May contain Nuts!
Travis Gatlin
17
Years of Service
User Offline
Joined: 14th May 2009
Location: Oxford, Alabama
Posted: 9th May 2011 04:34
Oh, well good point, but how do i change the direction of the raycast?

KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 9th May 2011 05:18
By giving it a different end point.

You are currently doing a raycast from point A to point A. Change it to point A to point B and it will go that direction.

Travis Gatlin
17
Years of Service
User Offline
Joined: 14th May 2009
Location: Oxford, Alabama
Posted: 9th May 2011 05:26
Ok, maybe i didn't word this right, i want the Ray to change direction in relation to the angle of the camera, so i want it to cast a line straight ahead in the direction i'm facing, how would i do that?

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 9th May 2011 06:21
use the camera's position and the position returned by the "pick screen" command.


Tell me if there's a broken link to images in a thread I post, and I'll fix 'em.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 9th May 2011 13:20 Edited at: 9th May 2011 13:20
Get camera coords as oldxyz, move the camera forward, get the new coords as newxyz, move your camera back. You have your raycast line of sight then.

Warning! May contain Nuts!
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 9th May 2011 18:12
Ah, I see what you're after now.



That should detect any collision in front of the camera within a 100 unit distance.

Travis Gatlin
17
Years of Service
User Offline
Joined: 14th May 2009
Location: Oxford, Alabama
Posted: 10th May 2011 00:34
Ok, thanks, i thought i worded it wrong in the first place, but will this work with gunfire?

/offtopic
@KISTech
i see that you live in Portland, do you know anyone by the name of Joshua Wright? he's one of my friends and he moved there last summer.
\offtopic

KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 10th May 2011 01:42
It should work, depending on how you make use of it.

Portland is a relatively big place, with nearly 2 million people in the metro area, so I'm not to surprised that the name doesn't sound familiar.

Travis Gatlin
17
Years of Service
User Offline
Joined: 14th May 2009
Location: Oxford, Alabama
Posted: 10th May 2011 01:57
Oh, ok, thanks, hopefully this'll work.

Login to post a reply

Server time is: 2026-07-11 04:24:26
Your offset time is: 2026-07-11 04:24:26