View unanswered posts | View active topics It is currently Thu Dec 26, 2024 5:43 pm



Reply to topic  [ 1 post ] 
 Having some problems with ObstacleRays *SOLVED* 
Author Message
User avatar

Joined: Fri Feb 16, 2007 8:43 pm
Posts: 1695
Location: AH SHIT FUCK AUGH
Reply with quote
Post Having some problems with ObstacleRays *SOLVED*
So yeah, i'm currently making a lightning gun. It works all fine, up until you start checking for collisions with anything. Here's how i'm doing the collision check, with irrelevant code cut out:
Code:
        local checkVector = glow.Pos - oldPos;
        if i > 1 then
            local impactLength = SceneMan:CastObstacleRay(oldPos, checkVector, Vector(0, 0), endPos, glow.ID, 0, 0);
            local trueLength = SceneMan:ShortestDistance(oldPos, endPos, true).Magnitude;
            if trueLength < checkVector.Magnitude then

The values of glow.Pos and oldPos don't matter (i think, tell me if they do), the important part is that oldPos is the previous value of glow.Pos, so as to draw a vector in between those positions. The problem is that checkVector.Magnitude and trueLength almost always have different values, with trueLength usually being the smallest of the two. I'm pretty sure that they should give identical values unless the ray actually hits something that isn't air, yet it insists on exploding right in front of the unfortunate user. Any ideas on why this is happening? The deviations are usually quite small, but can be by as much as 1.

Edit: Also, another anomaly: trueLength is sometimes smaller than 3. Why is this odd? Well, because the next point is always at least 3 pixels away. Y'know, ♥♥♥♥ secrecy, here's the mod so far. Also, pastebin for the lazy. Don't mind all the prints, it's just for checking. Any help would be greatly appreciated.

Edit2: Wait, minor cockup. Where it says "if trueLength < checkVector then" it should say "if trueLength < checkVector.Magnitude then".

EDIT 3: I figured it out. The problem? Apparently ObstacleRays are moderately retarded, so i did the following:
1. Cast MORay of desired length.
2. Use GetLastRayHitPos to determine impact point.
3. SceneMan:ShortestDistance the start and end points.
4. Glory.

Thread can be locked now, unless you want me to explain it better.


Sat Sep 25, 2010 5:33 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.126s | 13 Queries | GZIP : Off ]