Results 1 to 4 of 4
  1. #1
    MSgt. Shooter Person
    Join Date
    Apr 2010
    Posts
    56

    Default How to improve physics quality for rigid bodies.

    Hey guys, not sure if this is best put in the programming section, but I'm fairly sure the problem can't be fully resolved with the editor. I looked around for discussion of this, but haven't found anything that addresses my concerns.

    I'm making a game that is primarily physics driven, using small numbers of objects that the player interacts with. They mostly don't interact with each other, so I'm not doing anything crazy like "brick walls made of rigid bodies" or anything that requires a ton of collisions. The game is relaxed and doesn't have any combat. The problem is that all of the physics objects are still extremely "janky," for lack of a better term. Every time the objects collide with a surface they jerk all over the place. I have a fence that I wanted to be pushable by the player, and works fine at a rough pass, but it's extremely easy to push in a way that causes the physics to "jerk" or bump the character in a really obnoxious way. I'm also using constraints on objects to to create drawers, etc, but I can't seem to stop them from getting stuck in the dresser object or jerking violently when pulled out, which doesn't seem like it should be happening when the object is only able to move on one axis. I have been able to throw objects through walls by moving them too fast, and if an object is too small it can just fall through the floor. All of this really breaks the feel of the game.

    So, my question is this; what would you recommend I do to either improve the accuracy of rigid body collisions, to limit the speed at which an object can move (preventing the wild jerking when colliding), or generally just minimize collision issues? My game is focused on these uses of physics, so i don't care if the performance is reduced, but it is extremely detrimental to the feel of the game to have such easily "broken" physics. I would be happy to sacrifice some of the "flexibility" of objects in order to get rid of these issues. I also would be okay if the objects can't move very fast, or even can't rotate much, but so far all of the "spring" properties (such as the stay upright one) actually seem to make these issues more apparent.

    It this is more of an editor solution, I apologize, but I feel like the answer will be in code. Thanks a bunch.

  2. #2

    Default

    Jerking: The collision mesh may be too complex. I had a complex mesh once that did the same thing, changed its collision to a sphere and problem was solved (of course, then you have the issue of some of its parts going through things...)

    Drawer getting stuck: Again, collision. The meshes may be too tight, causing the engine to think they're colliding (constraints won't have any effect on this). Also may be a friction issue.

    Throw objects through walls: In the Tick() function, trace ahead to determine if you're about to hit something. If you are, cache it and then in every succeeding tick make sure you haven't gone past it. This is the only way I know to get around this problem, which I've also faced.

    Fall through fall: Small mass = massive velocity change. Same issue as above, it's just accelerating too quickly for you to notice it.

    Physics are not broken, they're just dependent on editor ticks which is really the root of every KActor problem i've had so far.
    Try my game Never End, now on the App Store! For more info, see the release thread.

    My Blog: WillyG Productions - Your Premiere UDK Resource
    My YouTube Channel: WillyG Productions
    My Facebook Page: WillyG Productions

  3. #3
    MSgt. Shooter Person
    Join Date
    Apr 2010
    Posts
    56

    Default

    Thanks, that's actually really helpful. Tracing ahead seems like it would be useful. You wouldn't happen to have a code snippet that I could take a look at, would you? My experience with this stuff is a little limited, so that would definitely help me. If not, I'll just dig around a bit. Thanks again.

  4. #4

    Default

    Try this:

    Code:
    simulated event Tick(float DeltaTime)
    {
    	local Vector HitLocation, HitNormal;
    	local TraceHitInfo HitInfo;
    	local Actor Other;
    	
    	super.Tick(DeltaTime);
    
    	Other = Trace(HitLocation, HitNormal, Location + Velocity * DeltaTime, Location, true, vect( 2, 2, 2 ), HitInfo, TRACEFLAG_Bullet);
    	if(Other != none)
    	{		
    		StaticMeshComponent.SetRBPosition(HitLocation);
    		StaticMeshComponent.SetRBLinearVelocity(MirrorVectorByNormal(Velocity, HitNormal) * 0.85, false);
    	}
    }
    Try my game Never End, now on the App Store! For more info, see the release thread.

    My Blog: WillyG Productions - Your Premiere UDK Resource
    My YouTube Channel: WillyG Productions
    My Facebook Page: WillyG Productions


 

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.