User Tag List

Results 1 to 8 of 8
  1. #1
    Whicked Sick Higor's Avatar
    Join Date
    Apr 2012
    Location
    Full sail ahead!
    Posts
    3,676
    Country:

    Code review: Jetpack

    Making the Jetpack work properly, at any tickrate.

    Not kind of sure here, but try:

    Adding this variable to the class:
    Code:
    var float aTimer;

    And replacing all state code with this one:
    Code:
    state Activated
    {
    	simulated function BeginState()
    	{
    		local UT_Invisibility inv;
    		if ( Role == ROLE_Authority )
    		{
    			if ( Owner.Physics != PHYS_Falling || Fuel <= 0 )
    			{
    				GotoState('DeActivated');
    				return;
    			}
    
    			bActive = true;
    			ClientActivate();
    
    			// Effects
    			inv = UT_Invisibility(Pawn(Owner).FindInventoryType(class'UT_Invisibility'));
    			if ( Trail == None )
    				if ( inv == None || inv.charge < 160)
    					Trail = Spawn(class'JetTrail', Owner);
    		}
    
    		// Physics
    		if ( PlayerPawn(Owner) != None && SimFall )
    			Pawn(Owner).bSimFall = true;
    		
    		aTimer = 1 / ThrustFrequency;
    	}
    
    
    	simulated function EndState()
    	{
    		local sgSpeed sp;
    
    		sp = sgSpeed(Pawn(Owner).FindInventoryType(class'sgSpeed'));
    		if (sp != None)
    			sp.GotoState('Activated');
    
    		if ( Role == ROLE_Authority )
    		{
    			bActive = false;
    
    			ClientDeactivate();
    
    			// Effects
    			if ( Trail != None )
    			{
    				Trail.Destroy();
    				Trail = None;
    			}
    		}
    
    		// Physics
    		if ( PlayerPawn(Owner) != None )
    			Pawn(Owner).bSimFall = false;
    	}
    	
    	simulated event Tick( float Delta)
    	{
    		if ( aTimer <= 0 )
    		{
    			aTimer += 1 / ThrustFrequency;
    			UserTimer();
    		}
    		aTimer -= Delta;
    		Fuel = FMax(Fuel - Delta, 0);		
    	}
    	
    	simulated function UserTimer()
    	{
    		local vector horizVel;
    		local rotator rot;
    		local sgSpeed sp;
    		
    		if ( Role == ROLE_Authority && (Owner.Physics != PHYS_Falling || Fuel <= 0) )
    		{
    			GotoState('DeActivated');
    			return;
    		}
    
    		sp = sgSpeed(Pawn(Owner).FindInventoryType(class'sgSpeed'));
    		if (sp != None)
    			sp.GotoState('DeActivated');
    	
    		horizVel = Owner.Velocity * vect(1,1,0);
    		rot.Yaw = Owner.Rotation.Yaw;
    		if ( cos((rotator(horizVel).Yaw - rot.Yaw)/32768*pi) *
    		  VSize(horizVel) < MaxHorizVel )
    			Owner.Velocity += vector(rot) * HorizThrust * 1 / ThrustFrequency;
    
    		if ( Owner.Velocity.Z < MaxVel )
    			Owner.Velocity.Z = FMin(Owner.Velocity.Z + Thrust * 1 / ThrustFrequency, MaxVel);
    
    	}
    
    	exec function ToggleJetpack()
    	{
    		GotoState('DeActivated');
    	}
    }
    
    
    state DeActivated
    {
    	simulated event Tick( float DeltaTime)
    	{
    		Fuel = FMin(Fuel + RechargeRate * deltaTime, MaxFuel);
    	}
    }

  2. #2
    Administrator SAM's Avatar
    Join Date
    Jan 2011
    Posts
    8,296
    Country:
    SW compiled a test version a couple days back. The jetpack was still tick dependant....

  3. #3
    Whicked Sick Higor's Avatar
    Join Date
    Apr 2012
    Location
    Full sail ahead!
    Posts
    3,676
    Country:
    Bah, if it was on me, I'd just rewrite the jetpack from scratch with an entire physics system.

  4. #4
    Rampage Feralidragon's Avatar
    Join Date
    Jan 2011
    Posts
    374
    Country:
    Quote Originally Posted by Higor View Post
    Bah, if it was on me, I'd just rewrite the jetpack from scratch with an entire physics system.

  5. #5
    Administrator SAM's Avatar
    Join Date
    Jan 2011
    Posts
    8,296
    Country:
    Quote Originally Posted by Feralidragon View Post
    This, do it :P

  6. #6
    Moderator .seVered.]['s Avatar
    Join Date
    Jun 2011
    Location
    Near a River and Under a Bridge
    Posts
    2,125
    Country:
    Quote Originally Posted by Feralidragon View Post
    Quote Originally Posted by $carface View Post
    This, do it :P
    Now all you need is a thumbs up from WildCard and you've got yourself a HatTrick!

    --- Updated ---


    What do you mean IF it was up to you?
    Quote Originally Posted by Higor View Post
    Bah, if it was on me, I'd just rewrite the jetpack from scratch with an entire physics system.
    Last edited by .seVered.][; 05-31-2012 at 09:33 PM.

  7. #7
    Rampage nOs*Wildcard's Avatar
    Join Date
    Jan 2011
    Posts
    313
    I still... Live.

    I absolutely despise the jetpacks performance. I will do someting. BTW Does this siege have my jetpack mesh working? I thought I heard somone making it work.
    It works on my mysterious unheard works with SX3, not perfect but pretty good. obviously not a priority of mine

    Oh BTW SPAM VICTORY!

    Website: http://gauntletwarriors.com/

  8. #8
    Whicked Sick Higor's Avatar
    Join Date
    Apr 2012
    Location
    Full sail ahead!
    Posts
    3,676
    Country:
    Just throwing some ideas, haven't been able to properly determine what is making the engine draw a flag on a player's back when he picks it up, but it does work.

    Thing is simple: you grab a jetpack, a new bAlwaysRelevant jetpack mesh decoration is created and referenced in that player's PRI HasFlag value.
    Also, make sure the item is set to bHidden=true so it isn't drawn somewhere other than the player's back.

    In the attached screenshot, you can see my character carrying a box.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Code review: Jetpack
    By Higor in forum #siegepug Discussion
    Replies: 7
    Last Post: 06-01-2012, 04:19 PM
  2. Code review: sgTeleporter
    By Higor in forum #siegepug Discussion
    Replies: 12
    Last Post: 05-26-2012, 08:24 PM
  3. Code review: Mines 2
    By Higor in forum #siegepug Discussion
    Replies: 5
    Last Post: 05-26-2012, 02:49 PM
  4. Code review: sgProtector
    By Higor in forum #siegepug Discussion
    Replies: 9
    Last Post: 05-24-2012, 03:21 PM
  5. Code review: Mines
    By Higor in forum #siegepug Discussion
    Replies: 20
    Last Post: 05-21-2012, 09:36 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •