Data Realms Fan Forums http://45.55.195.193/ |
|
Stopping things rotating. http://45.55.195.193/viewtopic.php?f=73&t=21191 |
Page 1 of 1 |
Author: | Dylanhutch [ Thu Jan 20, 2011 10:51 am ] |
Post subject: | 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. |
Author: | mail2345 [ Fri Jan 21, 2011 1:55 am ] |
Post subject: | 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. |
Author: | Dylanhutch [ Fri Jan 21, 2011 2:03 am ] |
Post subject: | 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? |
Author: | mail2345 [ Fri Jan 21, 2011 3:47 am ] |
Post subject: | 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). |
Author: | Dylanhutch [ Fri Jan 21, 2011 4:43 am ] |
Post subject: | 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? |
Author: | mail2345 [ Fri Jan 21, 2011 6:48 am ] |
Post subject: | Re: Stopping things rotating. |
On creation? ActivityMan:GetActivity():SwitchToActor(self,<player number>, self.Team) |
Author: | Dylanhutch [ Fri Jan 21, 2011 7:09 am ] |
Post subject: | 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. |
Author: | Coops [ Fri Jan 21, 2011 9:59 am ] |
Post subject: | 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. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |