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.

Dark Physics & Dark A.I. & Dark Dynamix / Ray casting to detect bullet hit

Author
Message
Neptune
13
Years of Service
User Offline
Joined: 8th Jan 2006
Location: United Kingdom
Posted: 5th Aug 2006 19:20
Hi, I can get ray casting to work put it only seems to point in a very angular way. Let me explain. I can cast a ray from say x,y,z but the direction in which the ray is cast is just say, left, right, up, down. I cant seem to point it in the direction an object is facing. Did that make sense?

So, i have a hidden box being controlled by the charater controller. Now if i want to fire a bullet (with out firing a physical object) in the direction you are facing it wont work.

Am I missing something?

Thanks again
HowDo
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 5th Aug 2006 19:28
I would say make a small demo ,eg object bullet then Mike will be able to check if its working right, plus you can prove to yourself that its doing what you think it should.

Plus have you used the debug tool.

I'm not getting you down am I, Ho Look! another fancy Door?
Neptune
13
Years of Service
User Offline
Joined: 8th Jan 2006
Location: United Kingdom
Posted: 5th Aug 2006 19:31
I cant use the debug tool at the minute DBP crashes when i run in debug mode. It says ' DBPCompiler.exe has encountered a problem and needs to close. We are sorry for the inconvenience. '
But thats another problem!
HowDo
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 5th Aug 2006 19:34
the other debug tool by Ageia for seeing whats going on with object.

use

PHY ENABLE DEBUG

as the first line in your code.

I'm not getting you down am I, Ho Look! another fancy Door?
Neptune
13
Years of Service
User Offline
Joined: 8th Jan 2006
Location: United Kingdom
Posted: 5th Aug 2006 19:44
The debugger doesnt seem to show raycasts
HowDo
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 5th Aug 2006 19:49
Which Phy command are you using to do this.

I'm not getting you down am I, Ho Look! another fancy Door?
Neptune
13
Years of Service
User Offline
Joined: 8th Jan 2006
Location: United Kingdom
Posted: 5th Aug 2006 21:04
phy ray cast all shapes (x#, y#, z#, 0, -1, 0)

The last 3 parameters are the direction vectors. But they only allow 1 and -1. ie. left and right as opposed to an angle.
HowDo
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 5th Aug 2006 21:14
No wonder your finding hard its one of the commands not documented yet.

I'm not getting you down am I, Ho Look! another fancy Door?
Neptune
13
Years of Service
User Offline
Joined: 8th Jan 2006
Location: United Kingdom
Posted: 5th Aug 2006 21:16
True , lol! It is mentioned in the tutorials though.
HowDo
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 5th Aug 2006 21:19
Ah I'll have a look there.

I'm not getting you down am I, Ho Look! another fancy Door?
HowDo
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 5th Aug 2006 21:27
Ok, which ones Phy commands are you using to find the object you wish to hit.

I'm not getting you down am I, Ho Look! another fancy Door?
Neptune
13
Years of Service
User Offline
Joined: 8th Jan 2006
Location: United Kingdom
Posted: 5th Aug 2006 21:42
Well, start off with something like:

and then:


I mean, that works fine - no problems at all. The problem is in controlling which direction the ray is cast. I want to set any angle. Instead, it just seems to work in 90 degree angles.
HowDo
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 5th Aug 2006 21:59
I've tired the demo code but all I get is could not understand command at line XXX which is

phy ray cast all shapes (x#, y#, z#, 0, -1, 0)

do you get and error for this command.

I'm not getting you down am I, Ho Look! another fancy Door?
Neptune
13
Years of Service
User Offline
Joined: 8th Jan 2006
Location: United Kingdom
Posted: 5th Aug 2006 22:12
Its a mistake in the tutorial. That command returns a value so you have to do:

something = phy ray cast all shapes (x#, y#, z#, 0, -1, 0)
HowDo
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 5th Aug 2006 22:13
Ah yes () means it returns something.

I'm not getting you down am I, Ho Look! another fancy Door?
Fallout
16
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 5th Aug 2006 22:14
The three numbers at the end describe a vector. They don't have to be just -1, 0 or 1. They can be any number and specifically, decimal points. While 0,0,1 describes a direction down the Z axis and 1,0,0 describes a direction down the X axis, 1,0,1 describes as direction half way between the X and Z axis, as does 0.5,0,0.5.

The easiest way to get your vector if you don't understand the maths is this:

Point your object in the direction you want to ray cast.
Save the object position.
Move the object forward 1.
Save the new position.
Move the object back 1 (to put it back to where it was).
Then use the old and new position to make the vector.

In code that looks like this:


Neptune
13
Years of Service
User Offline
Joined: 8th Jan 2006
Location: United Kingdom
Posted: 5th Aug 2006 22:34
Thanks for that. I will give it a try.
HowDo
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 5th Aug 2006 22:56
Neptune just like to say cheers for getting me to understand this by trying to help you now I am a little wiser.

I'm not getting you down am I, Ho Look! another fancy Door?
Neptune
13
Years of Service
User Offline
Joined: 8th Jan 2006
Location: United Kingdom
Posted: 6th Aug 2006 16:37
Hey HowDo, no bother lol! Its the best way to learn this new expansion, helping each other.
HowDo
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 6th Aug 2006 16:41
I find it great beening there at the begin makes us clever clogs later on.

I'm not getting you down am I, Ho Look! another fancy Door?
Neptune
13
Years of Service
User Offline
Joined: 8th Jan 2006
Location: United Kingdom
Posted: 6th Aug 2006 17:40 Edited at: 6th Aug 2006 17:41
Fallout: Thanks for that vector calculation - so simple! Worked a treat. Check out the pic - it detects the cube (object 99) pixel perfect!

HowDo: Very true

Attachments

Login to view attachments
Neptune
13
Years of Service
User Offline
Joined: 8th Jan 2006
Location: United Kingdom
Posted: 6th Aug 2006 17:59
Ach! The other ray cast commands dont work! I think you had the same problem in another thread Fallout? Doh! So close. When these are working I should be able to apply a force on the object at a specific point. Nice
Fallout
16
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 6th Aug 2006 18:33
Yeah, unfortunately none of them work except the ray cast itself, the hit and the object that was hit commands. I have a similar problem as you at the moment. I'd just apply force to the centre of the object for now until fixed.

Login to post a reply

Server time is: 2019-08-26 10:11:32
Your offset time is: 2019-08-26 10:11:32