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



Reply to topic  [ 8 posts ] 
 Aiming direction 
Author Message
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Aiming direction
How can I make an AEmitter have the RotAngle of where the parent actor is aiming?
If I set (considering I already did the code for who is the parent) self.RotAngle = self.parent.RotAngle would work?


Wed Mar 09, 2011 9:48 pm
Profile
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post Re: Aiming direction
You'd want something like this instead since aiming angle has its own function.

Code:
self.<Emitter>.RotAngle = self.<Actor>:GetAimAngle(true)


or if you always want the guns angle just get the gun's angle itself.

If you get the actor's Rotational Angle then your getting the angle his torso is. I believe GetAimAngle gets the angle of the head or where your cursor is aiming in respect of the selected actor.


Thu Mar 10, 2011 12:18 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Aiming direction
Wait, so it would be better to get the gun's aim angle??

Code:
function Create(self)
    local curdist = 50;
    for actors in MovableMan.Actors do
   local avgx = actors.Pos.X - self.Pos.X;
   local avgy = actors.Pos.Y - self.Pos.Y;
   local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
   if dist < curdist then
       curdist = dist;
       self.parent = actors;
   end
    end

end

function Update(self)
 self.RotAngle = self.parent.RotAngle
 end

This is my code so far. I tried to get the gun's angle, but I don't know how to do that.


Thu Mar 10, 2011 1:21 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post Re: Aiming direction
No. Aim angle only applies to things that can see. (Actors, AHumans and ACrabs)


Thu Mar 10, 2011 1:25 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Aiming direction
So it would be the guns RotAngle?


Thu Mar 10, 2011 1:26 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post Re: Aiming direction
The actor's aim angle.


Thu Mar 10, 2011 1:32 am
Profile
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post Re: Aiming direction
GetAimAngle only works on Actors, just like Roast Veg said. To get a non-actor's Rotational Angle, use .RotAngle like you are now.

Just use the aim angle method I gave you.

Replace the
Code:
self.RotAngle = self.parent.RotAngle

with
Code:
self.RotAngle = self.parent:GetAimAngle(true)

and it should work.


Thu Mar 10, 2011 1:40 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Aiming direction
Hey, it works!
Thanks guys.


Thu Mar 10, 2011 8:09 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.245s | 13 Queries | GZIP : Off ]