Topic: Rayhit point

Hey, the point that you get from the rayhit-function. Can you get that somehow to match with different objects so you can make scripts depending on what it hits?

Re: Rayhit point

You add the object you want to test as last parameter :

point = rayHit(start, end, object)
if point then
    -- you hit "object"
end

Re: Rayhit point

You are awesome. Thanks.

Re: Rayhit point

A = getObject("A")
C = getObject("C")

Apos = getPosition(A)
Cpos = getPosition(C)

and then this code:


point = rayHit(Apos, Cpos, weapon_salesman)
   
if onKeyDown("MOUSE_BUTTON1") and firing == 1 and derringer == true  then
        if point then
        print("you hit weapon salesman")
        end
elseif onKeyDown("MOUSE_BUTTON1") and firing == 1 and shotgun == true  then
        if point then
        print("you hit weapon salesman")
        end
end


So is this code right?

Last edited by Pär (2013-01-13 20:50:06)

Re: Rayhit point

if Cpos is far away enough it should be

Re: Rayhit point

Hm, the distance is dx 100 and it works when i'm leaving out the salesman and aiming at something with physics?

And when I shoot the salesman is between a and c but it doesn't register. :s

Last edited by Pär (2013-01-13 22:37:54)

Re: Rayhit point

Your script is good, the problem comes from Maratis, I just found a bug.
The 3rd argument with the object was not implemented correctly in the code... oups

Re: Rayhit point

That's alright. Hope we get it soon. smile

Re: Rayhit point

Can you write me what point Apos, Bpos is compared to so that I can make a table and make a if true statement then hit lets say weapon_salesman?

Re: Rayhit point

The code is corrected on svn, but I won't build it before the next version is ready,
you can build it yourself by installing a compiler (visual studio for windows, or gcc for unix), python and scons and by getting the code from svn.

Re: Rayhit point

How convenient that I have just began a programming course in school then. smile