1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Changing PhysicsVolume values via a trigger

Discussion in 'Programming' started by wattoo, Oct 9, 2005.

  1. wattoo

    wattoo New Member

    Joined:
    Oct 9, 2005
    Messages:
    5
    Likes Received:
    0
    Hello,

    I've looked on various forums and searched websites, but to no avail. I'm trying to find out if it's possible (and how easy for a beginner) it is to toggle the physics volume on and off.

    So if I have a physicsvolume with gravity set to x0 y0 z3000 I can press a trigger which ignores the volume and just uses the level's default of x0 y0 z-950.

    Any ideas?

    Cheers guys
     
  2. zest

    zest New Member

    Joined:
    Jul 28, 2005
    Messages:
    16
    Likes Received:
    0
    Last edited: Oct 20, 2005
  3. draconx

    draconx RuneUT

    Joined:
    Jun 26, 2002
    Messages:
    325
    Likes Received:
    0
    I entered the terms "Trigger Physics Volume" into the forum search and POOF! The thread zest posted appeared!
     
  4. wattoo

    wattoo New Member

    Joined:
    Oct 9, 2005
    Messages:
    5
    Likes Received:
    0
    You're a funny little boy.

    I already found Zest's post, but since it's talking about SOMETHING ELSE, I thought I'd see if anyone knew how to solve MY problem.
     
  5. draconx

    draconx RuneUT

    Joined:
    Jun 26, 2002
    Messages:
    325
    Likes Received:
    0
    In fact they're not talking about something else, and the precise solution to your problem is in that thread.
     
  6. zest

    zest New Member

    Joined:
    Jul 28, 2005
    Messages:
    16
    Likes Received:
    0
    He's correct, my bad, they are not the same thing, because all you can trigger is turning on bPaincauseing and it doesn't show how to trigger a gravity change.

    Maybee you could code something that triggers a change in the priorty of a volume, and have 2 volumes over lapping, a regular gravity one, and your 3000 gravity one.
     
  7. SuperApe

    SuperApe Registered Monkey

    Joined:
    Mar 20, 2004
    Messages:
    333
    Likes Received:
    0
    You'd want something like this:
    Code:
    //=============================================================================
    // TriggerGravityVolume.
    // Allow Gravity to be Trigger Toggled as well as the bPainCausing property.
    // by SuperApe -- Oct 2005
    //=============================================================================
    class TriggerGravityVolume extends PhysicsVolume;
    
    function Trigger( Actor Other, Pawn EventInstigator )
    {
    	Super.Trigger( Other, EventInstigator );
    
    	if ( Gravity == BACKUP_Gravity )
    		Gravity = vect(0,0,1) * int(Level.DefaultGravity);
    	else
    		Gravity = BACKUP_Gravity;
    }
    Subclass PhysicsVolume (right-click and select New...) and replace what's there by default with this. Compile and add as per normal volume. Seems to work fine. Should be fine online as well. (EDIT: Confirmed it does work fine online)

    If you didn't want to use the LevelInfo's default Gravity for some reason (say you have a couple different Gravity volumes in your map and you wanted this to either shoot a player up or default to some other PhysicsVolume's Gravity), you could do this:

    Code:
    //=============================================================================
    // TriggerGravityVolume.
    // Allow Gravity to be Trigger Toggled as well as the bPainCausing property.
    // by SuperApe -- Oct 2005
    //=============================================================================
    class TriggerGravityVolume extends PhysicsVolume;
    
    var()     bool     bUseCustomGravity;
    var()     vector     CustomGravity;
    
    function Trigger( Actor Other, Pawn EventInstigator )
    {
    	Super.Trigger( Other, EventInstigator );
    
    	if ( Gravity == BACKUP_Gravity )
    	{
    		if ( !bUseCustomGravity )
    			Gravity = vect(0,0,1) * int(Level.DefaultGravity);
    		else
    			Gravity = CustomGravity;
    	}
    	else
    		Gravity = BACKUP_Gravity;
    }
     
    Last edited: Oct 21, 2005
  8. zest

    zest New Member

    Joined:
    Jul 28, 2005
    Messages:
    16
    Likes Received:
    0
    Man your allways a great help thanks :)
     
  9. wattoo

    wattoo New Member

    Joined:
    Oct 9, 2005
    Messages:
    5
    Likes Received:
    0
    cheers guys. i'll give it a go
     

Share This Page