View unanswered posts | View active topics It is currently Fri Mar 29, 2024 2:20 pm



Reply to topic  [ 2 posts ] 
 2 questions 
Author Message
User avatar

Joined: Sat Jun 19, 2010 5:02 pm
Posts: 331
Location: Mekkan
Reply with quote
Post 2 questions
I have 2 questions that are somewhat related, at least for my purposes. The first one is easier. If you know one, but not the other, feel free to answer! Everything helps. Thanks! :grin:

1. In a script attached to a gun, how do you tell both if an actor is holding the gun, and if so, which actor is holding the gun?

2. In a script attached to a gun, how do I cast an ObstacleRay based on the current direction of the gun which skips 5 pixels and sets the Vector self.pointpos to the result of the ray? And how can I set how far it's allowed to search? I don't want TOO much lag. And how can I tell if it actually found a point or not?


Sat Sep 10, 2011 1:07 am
Profile
DRL Developer
DRL Developer

Joined: Tue Aug 11, 2009 5:09 am
Posts: 395
Reply with quote
Post Re: 2 questions
1. All MovableObjects have and ID and a RootID. If the ID and RootID are the same, the object is not held by any actor. If the ID and RootID are different, the object is held or carried by another MO and you can get a pointer to that MO by doing MovableMan:GetMOFromID(self.RootID).

2. Use self.MuzzlePos as the starting position. Use self:RotateOffset(Vector(n,0)) to get a vector that is n pixels long in the direction of the gun's barrel and use this vector as the vector to trace along. The ray will be n pixels long. Then consult the excellent API documentation to figure out the rest of the parameters. The return value will tell you if any pixel of the right material was found or not.


Sat Sep 10, 2011 7:51 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.157s | 17 Queries | GZIP : Off ]