UE3 - UDK How do I make the barrel fall, but not fall through the floor?

  • 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.

Nathaniel3W

Member
Nov 11, 2012
48
0
6
I'm using the RemadePhysBarrel static mesh that's included with the UDK. I have a function that spawns one of these in front of me. I can make the barrel fall through the floor or stay in the air, but I can't make it fall and then stop when it hits the floor. How would I go about that?

Code:
class TestPhysicsBarrel extends Actor
	placeable;

DefaultProperties
{
	Begin Object class=StaticMeshComponent Name=TheMesh
		StaticMesh = StaticMesh'phystest_resources.RemadePhysBarrel'
		HiddenGame=FALSE
		HiddenEditor=FALSE
		Scale=1
	End Object
	Components.Add(TheMesh)
	CollisionComponent=TheMesh
	bMovable=True
	bCollideActors=true
    bBlockActors=true
	// Physics = Phys_Falling // If I use this, the barrel falls through the floor.
	// Physics = Phys_RigidBody // If I use this, the barrel doesn't fall at all.
}

event PostBeginPlay(){
	// SetPhysics(Phys_RigidBody); // If I use this, the barrel falls through the floor.
}
 

Nathaniel3W

Member
Nov 11, 2012
48
0
6
Thanks VendorX. I'm sure that using Actor instead of KActor was part of my problem, but the barrel is still either staying in the air or falling through the floor. This is my code now:

Code:
class TestPhysicsBarrel extends KActor
	placeable;

DefaultProperties
{
	Begin Object class=StaticMeshComponent Name=TheMesh
		StaticMesh = StaticMesh'phystest_resources.RemadePhysBarrel'
		HiddenGame=FALSE
		HiddenEditor=FALSE
		Scale=1
	End Object
	Components.Add(TheMesh)
	CollisionComponent=TheMesh
	bMovable=True
	bCollideActors=true
    bBlockActors=true
	bStatic=false
	bNoDelete=false
	// If I don't set any physics, the barrel stays in the air
	// Physics = Phys_Falling // If I set this, the barrel falls through the floor.
	// Physics = Phys_RigidBody // If I set this, the barrel doesn't fall at all.
}


simulated event PostBeginPlay(){
	// SetPhysics(Phys_Falling); // If I use this, the barrel falls through the floor.
	// SetPhysics(Phys_RigidBody); // If I use this, the barrel stays in the air.
}

I get a warning in the log. Does this have anything to do with my problem?
Log: WARNING: Cooking Convex For Actor: SimpleCourtyard.TheWorld:persistentLevel.TestPhysicsBarrel_0 Component: StaticMeshComponent_3 StaticMesh: phystest_resources.RemadePhysBarrel (Scale: 1.000000 1.000000 1.000000) Please go and set PreCachedPhysScale on the mesh to have this scale for RunTime spawned objects.
 

VendorX

Member
Aug 2, 2010
231
6
18
BXL/Paris
1. Use existing StaticMeshComponent0 - is ready to use...
2. In KActor you have bWakeOnLevelStart option - set it to True. Go to KActor.PostBeginPlay to know what will happen...
3. Don't scale SM in this way - it cause more problems than benefits. Use SM with the right size...
4. Apart of TakeDamage all interactions like Pawn->Push->KActor or vice versa you need to implement by yourself.

For now, try this:
Code:
class TestPhysicsBarrel extends KActor
	placeable;

DefaultProperties
{
	Begin Object Name=StaticMeshComponent0
		StaticMesh=StaticMesh'phystest_resources.RemadePhysBarrel'
	End Object

	bWakeOnLevelStart=True
}
 

Nathaniel3W

Member
Nov 11, 2012
48
0
6
Ugh. Database error just deleted my heartfelt thanks. Well, let me say it again... Thanks VendorX. That worked perfectly. Barrels are now falling from the sky and bouncing and rolling around. Next up I'll make them be able to be pushed and whatever. Thanks again.