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.

DLL Talk / Raycasting bullets with "Accuracy"

Years of Service
User Offline
Joined: 11th Apr 2009
Posted: 14th Nov 2009 22:58 Edited at: 15th Nov 2009 00:24
Hi, I am using the Nuclear Glory Collision DLL to add RayCasting functionality to my game. What I want to do is have the ray go from Object 1 to Object 2. This is quite simple to do, but I want to add accuracy as it will be for my gun. For example, the ray will go from Object 1 to An area around Object 2. The problem is, my objects will rotate a lot, so I cannot just do:

RayIntersectTypePRO(COLL_TYPE, SHAPE_TYPE, Obj1X, Obj1Y, Obj1Z, Obj2X + Rnd(50)-25, Obj2Y + Rnd(50)-25, Obj2Z + Rnd(50)-25)

because this will make the rays go too far in some cases, and be to short in others (meaning that on a certain angle the ray wont get to object 2). How can I make sure that the ray always hits or goes past the object 2?

Now that I think of it, I would like bullets to go farther than Object 2 by a variable, Distance. This would be good for like a shotgun that misses with some shots, but they continue to hit things behind object 2.

If anything is unclear please ask, I really need help with this.

I also have DarkPhysics. Would this be better to use for my purpose? I want to add raycasting without actually adding physics.
Years of Service
User Offline
Joined: 6th Nov 2009
Location: NE PA, USA
Posted: 6th Jan 2010 19:03
I had a similar issue, what I did was to take the offset for the accuracy I calculated... in your case

offset2x = Obj2X + Rnd(50)-25

and then I offset the origin raycat position by a random of half of the offset but in the opposite direction i.e.

offset1x = Rnd((0-offset2x/2))

The result here gave the impression that with distance the accuracy appears to get worse.. For the being too accurate, you could use a minimum accuracy and if the result is less than this use this value, say 5... if the offset is <5 then set it to 5.

The issue with the range, I used a range value and only offset my target object to that range, then if I get no rayhit locations then it will give you the result you want...

Hope this help... By the way with NGC how do you deal with bullet hold placemant... I am struggling with this on hits on objects at abnormal angles.. I have a platform in my game that sits at 25degrees, mainly there for gravity and collision testing, but when I fire at it my bullet hole is at 90degress to me terrain plain... just thought if you have a thought on this?

eXtreme+ Crew

Login to post a reply

Server time is: 2020-06-01 00:41:11
Your offset time is: 2020-06-01 00:41:11