Results 1 to 14 of 14
  1. #1
    MSgt. Shooter Person
    Join Date
    Jun 2010
    Posts
    64

    Default Cap MaxZ and MinZ

    Hi!

    I'm trying to do a simple function that will cap my vehicle's Z value (both Max and Min). My plan is simply to check if my vehicle is above a Z-value (2500.0 at the moment) and then either set it back to 2500.0 or set the velocity to 0.

    Currently this is my very unfunctional code:

    Code:
    				
    function EndGame()
    {
    	`log(MyPos);
    	MyPos = self.Location;
    	MaxZHeight = 2500.0;
    
    	if (MyPos.Z > 2500.0)
    	{
    		//hopp = vect(MyPos.X,MyPos.Y,MaxZHeight);
    		MyPos.Z = MaxZHeight;
    		self.SetLocation(MyPos);
    		
    
    		
    	}
    }
    Could it have to do with the fact that I first declare that MyPos = self.Location and I after that change MyPos.Z?

    My other plan was to create a new vector (hopp), however the compiler complains that it is lacking a X, Y or Z-value (float MaxZHeight).
    I can't even write: hopp = vect(MyPos.X,MyPos.Y,MyPos.Z) something that confuses me.

    Thanks in advance =)

  2. #2
    Veteran
    Join Date
    May 2007
    Location
    Above KillZ, Below StallZ
    Posts
    9,953

    Default

    vect() requires constant values as it's a compiler directive not a function that creates a vector.

    Using "self" is a waste of time except as a function argument to something that requires an object reference.

    Code:
    function EndGame()
    {
        if(Location.Z > MaxZHeight)
        {
            MyPos = Location;
            MyPos.Z = MaxZHeight;
            SetLocation(MyPos);
        }
    }
    http://www.ericbla.de http://www.dungeondefenders.com http://en.wikipedia.org/wiki/Warm_Gun http://www.rekoil.com http://www.groundbranch.com

    - Please don't send me private messages asking programming questions, those would be better asked on the Programming forum here. Thanks

  3. #3
    MSgt. Shooter Person
    Join Date
    Jun 2010
    Posts
    64

    Default

    I see - I'll stop using self then =)

    Thanks a lot for the help with the code - makes sense.
    Another issue I ran into is the fact that this function lies in my vehicle-class though I'm wondering if I have to put it into my Pawn-class (or reference to it in my Vehicle-script)?

  4. #4
    Veteran
    Join Date
    May 2007
    Location
    Above KillZ, Below StallZ
    Posts
    9,953

    Default

    well that depends on if you want to be adjusting the Z location of the Vehicle or of the Pawn ?
    http://www.ericbla.de http://www.dungeondefenders.com http://en.wikipedia.org/wiki/Warm_Gun http://www.rekoil.com http://www.groundbranch.com

    - Please don't send me private messages asking programming questions, those would be better asked on the Programming forum here. Thanks

  5. #5
    MSgt. Shooter Person
    Join Date
    Jun 2010
    Posts
    64

    Default

    I got it to work quite alright on my Pawn, however nothing happens when I write it in my vehicle-class.

    Could it be that I need to refer to my PlayerController with this code when I'm in the vehicle?

    Edit: Alright, I tried to set use Set Location in my Vehicle-class but nothing really happens - except that the vehicle stops in a fixed location (no gravity) though not in the location that I have assigned.

    function EndGame()
    {
    MyPos = vect(0.0,0.0,0.0);
    SetLocation(MyPos);
    }
    Last edited by MrArgh; 04-05-2011 at 03:47 AM.

  6. #6
    Veteran
    Join Date
    May 2007
    Location
    Above KillZ, Below StallZ
    Posts
    9,953

    Default

    I'm sort of curious, what's the actual purpose of doing this, anyway?

    Probably need to call SetRBLocation on the Vehicle's Mesh, because it's a physics object, it doesn't follow a lot of the Unreal physics stuff
    http://www.ericbla.de http://www.dungeondefenders.com http://en.wikipedia.org/wiki/Warm_Gun http://www.rekoil.com http://www.groundbranch.com

    - Please don't send me private messages asking programming questions, those would be better asked on the Programming forum here. Thanks

  7. #7
    MSgt. Shooter Person
    Join Date
    Jun 2010
    Posts
    64

    Default

    I'm basically trying to create a boat using an extended Manta. Our plan is to include floating/buoyancy and I just want to make sure that the boat never gets higher/lower than a certain value - and this must apply both when driving and not driving the boat.

    If I try SetRBLocation, should this be done in my vehicle class or my vehicle content class? (My classes follow the same hierarchy as the regular manta).

  8. #8
    Veteran
    Join Date
    May 2007
    Location
    Above KillZ, Below StallZ
    Posts
    9,953

    Default

    Should be done wherever you have access to the Mesh. So why is the function called "EndGame()" if you're trying to make it regularly stay at a certain level? *confused*
    http://www.ericbla.de http://www.dungeondefenders.com http://en.wikipedia.org/wiki/Warm_Gun http://www.rekoil.com http://www.groundbranch.com

    - Please don't send me private messages asking programming questions, those would be better asked on the Programming forum here. Thanks

  9. #9
    MSgt. Shooter Person
    Join Date
    Jun 2010
    Posts
    64

    Default

    The function name is just stupid of me, it has nothing to do with what I want it to do. I just named it that when I started working on the function. When I get it to work I'll rename it =)

    Alright, so I'll try and use SetRBLocation on the Vehicle's mesh and see how that turns out. I'll most likely get back if it doesn't work.

    And, I don't mean to be an irritating question-asker, but do you have any idea on how to solve this: http://forums.epicgames.com/showthread.php?t=772150

    Anyway, thanks for the help!

  10. #10
    MSgt. Shooter Person
    Join Date
    Jun 2010
    Posts
    64

    Default

    Alright, my vehicle doesn't go above my desired MaxZValue - working as intended.
    One more thing I need to do is to set Velocity to 0 when it reaches this value. Is there something like SetLocation for Velocity?

    My code:

    Code:
    function CapHeight()
    {
    	
    	MaxZHeight = 2500.0;
    	`log(Velocity);
    	
    	
        if(Location.Z > MaxZHeight)
        {
        	MyPos = Location;
                 MyPos.Z = MaxZHeight;
    	Mesh.SetRBPosition(MyPos);
        }
    }
    I was thinking of AddVelocity but I'm kinda uncertain about the parameters.

  11. #11
    Veteran
    Join Date
    May 2007
    Location
    Above KillZ, Below StallZ
    Posts
    9,953

    Default

    I'd SetPhysics(PHYS_None); that should pretty much ensure it stops
    http://www.ericbla.de http://www.dungeondefenders.com http://en.wikipedia.org/wiki/Warm_Gun http://www.rekoil.com http://www.groundbranch.com

    - Please don't send me private messages asking programming questions, those would be better asked on the Programming forum here. Thanks

  12. #12
    MSgt. Shooter Person
    Join Date
    Jun 2010
    Posts
    64

    Default

    Indeed it stops =)
    The thing is, after that I need it to fall down again - so I tried setting Physics to RigidBody after Phys_None; the issue is that the vehicle still seem to have input from my jump (because it is pushed up when RigidBody physics is applied...).

    Edit: The easiest thing would be if there is a function in which I can set my Pawn/Vehicle's speed to 0 immediately. I tried to change both Velocity and Acceleration but not much happened. Unless I have to apply it to my Pawn(or vehicle mesh?) specifically?
    Last edited by MrArgh; 04-07-2011 at 02:00 PM.

  13. #13
    Veteran
    Join Date
    May 2007
    Location
    Above KillZ, Below StallZ
    Posts
    9,953

    Default

    open up PrimitiveComponent and have a look through the functions there?
    http://www.ericbla.de http://www.dungeondefenders.com http://en.wikipedia.org/wiki/Warm_Gun http://www.rekoil.com http://www.groundbranch.com

    - Please don't send me private messages asking programming questions, those would be better asked on the Programming forum here. Thanks

  14. #14
    MSgt. Shooter Person
    Join Date
    Jun 2010
    Posts
    64

    Default

    Thanks Blade - I found the answer there.
    I used: Mesh.SetRBLinearVelocity(MyVelocity);

    That more or less settles it - my function is done =)


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.