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



Reply to topic  [ 8 posts ] 
 Stopping things rotating. 
Author Message
User avatar

Joined: Sun Apr 25, 2010 12:04 am
Posts: 303
Location: Australia
Reply with quote
Post Stopping things rotating.
How could I stop a craft rotating through Lua?

I have tried this:

Code:
function Update(self)
   self.AngularVel = 0
   end


It doesn't show any errors but doesn't work for some reason, I bet this is something incredibly simple.


EDIT It's an ACRocket by the way.


Thu Jan 20, 2011 10:51 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Stopping things rotating.
Not sure what you're looking for, but you probably want to disable both the MOVE_LEFT and MOVE_RIGHT controller states if you just want to prevent turning.
If you really want to stop rotation, lock the rotation angle as well as velocity.


Fri Jan 21, 2011 1:55 am
Profile
User avatar

Joined: Sun Apr 25, 2010 12:04 am
Posts: 303
Location: Australia
Reply with quote
Post Re: Stopping things rotating.
mail2345 wrote:
Not sure what you're looking for, but you probably want to disable both the MOVE_LEFT and MOVE_RIGHT controller states if you just want to prevent turning.
If you really want to stop rotation, lock the rotation angle as well as velocity.


It is a drop crate class, so I don't need to prevent left and right controls, I need to stop it turning altogether.

As in, make it only go straight down and straight up.



EDIT
How would I lock the rotation angle?


Fri Jan 21, 2011 2:03 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Stopping things rotating.
self.RotAngle = <whatever, probably 0>

Also, if I understand you correctly, you might want to lock X vel to 0(self.Vel.X = 0).


Fri Jan 21, 2011 3:47 am
Profile
User avatar

Joined: Sun Apr 25, 2010 12:04 am
Posts: 303
Location: Australia
Reply with quote
Post Re: Stopping things rotating.
Thanks so much, It worked to perfection.

Also, very offtopic and you probably won't know, but how would I make it switch control to the craft?


Fri Jan 21, 2011 4:43 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Stopping things rotating.
On creation?
ActivityMan:GetActivity():SwitchToActor(self,<player number>, self.Team)


Fri Jan 21, 2011 6:48 am
Profile
User avatar

Joined: Sun Apr 25, 2010 12:04 am
Posts: 303
Location: Australia
Reply with quote
Post Re: Stopping things rotating.
Thanks, I'll be sure to credit you by the way.

Here is the final script:
Code:
function Create(self) --Don't really need this since I can just edit the ini but anyway.
    self.Vel.X = 0
    self.Vel.Y = 10
end
function Update(self)
if UInputMan:KeyHeld(19) then --If "S" is held, move down at 10 velocity.
   self.Health = 100            --Don't die either.
    self.Vel.X = 0                     --No jiggling for you!
    self.Vel.Y = 10                   --Move
end
if UInputMan:KeyHeld(23) then  --If "W" is held, explode.
   self:GibThis();
end                                      --Ends "then" and "if" so that rotating can be stopped each frame.
   self.RotAngle = 0            --Stops rotating.
   self.Vel.X = 0
   end                              --End mother****er.



I took this from a whole lot of different mods I have made in the past and put it all together.

It's for this.


Fri Jan 21, 2011 7:09 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: Stopping things rotating.
If you want this to be Gamepad friendly you should do it like this instead.

Code:
function Create(self) --Don't really need this since I can just edit the ini but anyway.
    self.Vel.X = 0
    self.Vel.Y = 10
end
function Update(self)
self.cont = self:GetController(); -- get controller
if self.cont:IsState(Controller.BODY_CROUCH) then --If down is held, move down at 10 velocity.
    self.Health = 100            --Don't die either.
    self.Vel.X = 0                     --No jiggling for you!
    self.Vel.Y = 10                   --Move
end
if self.cont:IsState(Controller.BODY_JUMPSTART) then  --If up is held, explode.
   self:GibThis();
end                                      --Ends "then" and "if" so that rotating can be stopped each frame.
   self.RotAngle = 0            --Stops rotating.
   self.Vel.X = 0
end                              --End mother****er.



Fri Jan 21, 2011 9:59 am
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.294s | 13 Queries | GZIP : Off ]