Download

Physics Simulation Test Case - Need Help

Hey Everyone!

I hope I am posting this in the proper location.
I am fairly new to C++ and the Unreal Engine architecture, but am trying to learn and become more familiar with it.

Here is what I am trying to achieve:

Test Case:

  • Ball Mesh (Particle Representation)
  • Pipe
  • The Ball (PR) needs to move in a direction with a set velocity down into the top portion of the pipe where it will collide with the inside wall of the pipe. As it collides, it gains speed and deflects where it collides yet again, deflecting it and causing it to gain even more speed. This process will continue until the Ball (PR) is moving at incredible speed and has stopped moving downward in the pipe but is deflecting off of the walls at a standstill level (these results must be as accurate as real life and need to be accomplished using the physics systems/engine within ue4). Performance is not an issue right now as this is going to be an experiment to simply spit out data that can be viewed after the simulation has been run.

Any help on where to start, what I need to look into, or any other tips would be great.

-Jeremy-

Hi there and welcome,
I’m a bit confused because you say that the results must be accurate to real life, but you want the ball to gain speed with each collision? Could you clarify what you mean?
Cheers

Dear Jeremy,

The must fundamental first issue is that as of 4.5 Epic still has not addressed the issue that you cannot use the Physics engine with static meshes whose collision is set to per poly (complex as simple).

I have already reported this issue here.

AnswerHub
https://answers.unrealengine.com/questions/75521/physics-per-poly-collision-doesnt-work-with-physic.html

To do what you are wanting the very first thing you will need is your concave pipe shape with proper physics collision.

Unless you did this by hand somehow I imagine you will want to wait until 4.6 / whenever we can use complex as simple with physics engine.

You can verify whether your imported collision worked, or if Auto Convex Collision was sufficient to the task, by going into your pipe static mesh editor and making sure Collision button is active so you can see current collision primitives.

If you dont want to wait till 4.6+, you will need to create the physics collision primitives by hand in your modelling program using UCX_NameOfYourFile and a bunch of convex shapes. *reference http://udn.epicgames.com/Three/FBXStaticMeshPipeline.html)

If you dont want to do the above you can try using auto convex collision but that typically wont be working too well for a long completely enclosed shape like a pipe.

Once you’ve found a way to address this first matter we can discuss the rest of your question :slight_smile:

:heart:

Rama

I have already successfully built all of the collision (and am able to run simple physics simulations already). I am wondering about the rest of the problem :slight_smile:
I guess I should have specified that I already had those elements working. I am more confused about giving objects velocity and specifying attributes (and how to implement them in c++).

-Jeremy-

Wouldn’t the ball gradualy loose speed/energy upon collision rather then gaining it?
I am just confused with the combination of the words like in real life, and something I have a hard time to percieve as a real life scenario. Otherwise we have just solved the problem of free energy.

I must have not worded this properly. My apologies.
Here is an image that will hopefully get the point across.

-Jeremy-

Dear Jeremy,

Are you using a Particle System Component Mesh, or an actual static mesh that is simulating physics?

Adding the impulses you want to a static mesh that is simulating physics each time it collides with the walls of the tube is quite do-able!

The first thing you need to do is verify you are getting the hit event for the static mesh actor!

So your particle needs to be extending AStaticMeshActor and override this event:

.h



virtual void ReceiveHit(class UPrimitiveComponent* MyComp, class AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit) override;


.cpp



void AVictoryWall::ReceiveHit(
	class UPrimitiveComponent* MyComp, 
	class AActor* Other, 
	class UPrimitiveComponent* OtherComp, 
	bool bSelfMoved, 
	FVector HitLocation, 
	FVector HitNormal, 
	FVector NormalImpulse, 
	const FHitResult& Hit
)
{
  //Verify you got here by sending output to yourself!
   GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Hit impulse!: %s), *NormalImpulse.ToString()  ));
}


If GEngine does not compile for you make sure your project is including Engine.h not EngineMinimal.h

Rama

PS: I can post a complete code sample once you verify that you are using a static mesh actor and that yes you need whole code sample

Rama! You are awesome :smiley:
Thanks for this! I am going to be reading over this and implementing it soon!

Will post an update soon. Thanks again!

PS: I am using a static mesh (not a particle). However, the static mesh is suppose to represent a particle (and will later need to behave like one).

-Jeremy-

Okay let me know how it goes! I can help you out as you get further along in this process any time!

Rama