Data Realms Fan Forums
http://forums.datarealms.com/

2 questions
http://forums.datarealms.com/viewtopic.php?f=73&t=25466
Page 1 of 1

Author:  Awesomeness [ Sat Sep 10, 2011 1:07 am ]
Post subject:  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?

Author:  Abdul Alhazred [ Sat Sep 10, 2011 7:51 am ]
Post subject:  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.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/