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.

Author
Message
Zhent
17
Years of Service
User Offline
Joined: 26th Jan 2007
Location: Cleveland
Posted: 5th May 2007 23:29
I'm trying to implement shooting using a physics raycast. This is what I should do, as far as I know [please correct me if I have the wrong idea]

When the player clicks the mouse, I need to cast a ray from the camera position and at the camera angle to all shapes. Then I check to see if it hit any object using the get ray cast hit command. if it does, i check to see whether it hit an enemy [get ray cast object, if between 150 and 160 it hit an enemy] and if it did, i delete the enemy.

So theres my understanding of a shooting function. Here's my problem: when I ray cast all shapes, I get the following error:

NxRay: direction not valid, must be unit vector.


this is the line that casts the ray.
temp = phy ray cast all shapes( camera position x(), camera position y(), camera position z(), camera angle x(), camera angle y(), camera angle z())

If anyone has any suggestions, please let me know. Thanks!

--
Zhent, coding newbie
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 6th May 2007 03:37 Edited at: 6th May 2007 03:41
I don't use Dark Physics so I can't give you any code help, however I will tell you that a unit vector is a vector that points in a particular direction while only having a length of 1 (thus dividing a vector by its length gives you a unit vector). For example:

unitX = x / sqrt(x^2 + y^2 + z^2)
unitY = y / sqrt(x^2 + y^2 + z^2)
unitZ = z / sqrt(x^2 + y^2 + z^2)

Where x, y, and z are components of a vector. Note that you can do this using the built-in vector commands, just that I thought I would explain this to you in case it might help with your current problem, or at least so that you know it for future reference.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
Zhent
17
Years of Service
User Offline
Joined: 26th Jan 2007
Location: Cleveland
Posted: 6th May 2007 18:16
So then how would I fix the error?

--
Zhent, coding newbie

Login to post a reply

Server time is: 2024-03-29 06:50:36
Your offset time is: 2024-03-29 06:50:36