View unanswered posts | View active topics It is currently Fri Jan 10, 2025 10:36 pm



Reply to topic  [ 6 posts ] 
 why wont this raycast work? 
Author Message
User avatar

Joined: Sat Mar 28, 2009 2:33 pm
Posts: 718
Reply with quote
Post why wont this raycast work?
Hey guys, im trying to make a code that lets things stab into things, thus stickying themself to the object they hit.
Im trying to do this by projecting a raycast in the direction that the stabber is moving, which finds all mos that are there, and then does a distance check to see if the distance is close enough for them to be touching. it should then jump to the mos position. it keeps giving me the same error about the raycast line of code when i try to use it. can anyone tell me what im doing wrong?
Attachment:
StuffPack.rte.rar [7.1 KiB]
Downloaded 153 times


Wed Apr 28, 2010 2:24 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: why wont this raycast work?
Which script has the problem, and what is the exact error?


Thu Apr 29, 2010 11:45 pm
Profile
User avatar

Joined: Sat Mar 28, 2009 2:33 pm
Posts: 718
Reply with quote
Post Re: why wont this raycast work?
CaveCricket48 wrote:
Which script has the problem, and what is the exact error?


ah. sorry, the script is the 'stick2stuff' file.
it keeps saying something about the raycast at line 8.


Fri Apr 30, 2010 2:12 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: why wont this raycast work?
In the MORay arguments, you have "RefPoint". And before that you have "self.RefPoint". You forgot the "self" in the argument.

Also, what's the point of this?
Code:
if 0 ~= 1 then


Sat May 01, 2010 5:49 pm
Profile
User avatar

Joined: Fri Feb 16, 2007 8:43 pm
Posts: 1695
Location: AH SHIT FUCK AUGH
Reply with quote
Post Re: why wont this raycast work?
I'm afraid there is a lot of faults in your Lua. It would become a major block of text if i wrote them in prose, so i'll give you a list:
- You forgot "self." in front of "RefPoint" in the MORay. (What Cricket said)
- You forgot "self." in front of "target" in every instance after defining it.
- Using Pythagoras to find distance is fine, but not optimal. See the function i used in the attached fix.
- You're casting the MORay even though it already has a target, making it able to change targets.
- You're not checking if the MORay has hit something, which leads to errors if it hasn't.
- You're not checking if the thing the MORay has hit is valid, which also can lead to errors.
- "if 0 ~= 1" is redundant and can safely be removed.
- The MORay can hit the object it's cast from if it isn't set to ignore "self.ID". (third argument in the MORay)
- self.RefPoint vector is way off. You should just be calling it "self.Vel/3" if you want it to check the distance in front of the arrow that it will travel in the next frame, unless you've screwed around with DeltaTime or PixelsPerMeter. In this case, you should do this: "self.Vel * TimerMan.DeltaTimeSecs * FrameMan.PPM" without the quotes.
- Making the MORay a local might (unsure of this) give problems.

I think that's about it. I apologize for hammering you like this, but most of the above has caused errors while i was testing it. Also, you might want to make the arrow HitsMOs = 0, as it will behave oddly if it isn't, due to it constantly colliding with the thing it's stuck to, as well as potentially not sticking due to the sprite being longer than the MORay.

Here's the fixed Lua. Hope you don't mind. I've included comments, but if they're inadequate, ask away. =P


Attachments:
File comment: :U
StickToStuff.rar [632 Bytes]
Downloaded 142 times
Sat May 01, 2010 6:09 pm
Profile WWW
User avatar

Joined: Sat Mar 28, 2009 2:33 pm
Posts: 718
Reply with quote
Post Re: why wont this raycast work?
many thanks.
edit;
uncle shook,
it still doesn't work right. i even changed it to hitsmos = 0 like you asked, but it just phases through people without sticking.
this is weird because it doesn't register any errors to console.


Sat May 01, 2010 6:33 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.134s | 14 Queries | GZIP : Off ]