How to add force to an actor in unreal engine? - unreal-engine4

I am using blueprints. I have an actor that I want to move using a physics force/impulse when they are spawned. Basically I want to push the actor when they are spawned. I have physics and gravity enabled.

Use the add impulse, or add force nodes.
Add impulse is designed to be used only once to add a burst at a location.
E.g hitting a golf ball.
Add force is designed to be used multiple times to gradually move objects.
E.g Player pushing a heavy cube
Use whichever is best suited for your needs.

Related

Is there any way to make a collider collide only with a specific GameObject without using layers?

Basicly I have a GameObject with BoxCollider attached to it and I want it to collide only with one specific BoxCollider, ignoring all other collisions. Is there any way to do that without using layers? I want to avoid using layers because I need that system to be as flexible as its possible.
I can technicly use Physics.IgnoreCollision but it will drastically lower game performance and I want to avoid it.
Although it is a 'trick' method, there is a way to add a specific class component only to a specific collider that you want to collide, and then, when processing it in another place, there is a way to determine the class.
Hope this helps.

Unity: Mixing Sprites in Particle System

So I have two sprites one for fire and another for ice.
I need to have a partial system that can take one or both sprites and spawn both of them.
For example, I have one particle system that spawns in a straight line and another that is in a cone. instead of creating two for each (one reach for fire and ice). I want to be able to add the ice sprtie to a list of sprites and have the particle system spawn a mix of both of them.
What is the best way to go about this?

UE4 My skeletal mesh won't simulate physics when in a socket

I am making a scale with chains that hold a plate.
The Scale Asset
I have the chain as a skeletal mesh with a physics asset. The part that the chains hang onto have sockets.
The chain
When I try to attach my chain to the asset, I have issues:
1) When I put the chain into the blueprint actor and assign it to its parent socket via the details panel...the chain will just fall off when simulated rather than hanging from where the socket is.
2) When I attach the chain to a socket via blueprints, the physics won't simulate at all. The chains just stay rigid.
example of the construction script
How can I get the chains to stay in place...while simulating physics?
Is there a better way I am just not using?
Thank you.
On your chain, in the physics asset, you need to select the physics capsule on the bone that is attaching to the socket and set it’s physics from default/simulating to kinematic. It disables physics on that one bone and will anchor instead of fall when you attach it.

Unity ignore collisions on the same layer

I want to use Physics.IgnoreCollision to avoid bullets hitting themselves.
The bullets are spawned on layer 8. Why is this not working? How can you ignore collisions with everything on the same layer?
// bulletscript.cs
gameObject.layer = 8;
// maingamescript.cs
Physics.IgnoreCollision(8,8);
There may also be other objects on layer 8 that should also be ignored.
(for example, the player ship).
Why not use the handy dandy Physics Manager. Go to Edit->Project Settings-> Physics and set up the proper layer collisions.
Go to Physics Manager and un-check the layer with itself to avoid collision.
Troubleshot:
Unity bug, try to update to latest Unity 5.3.x (5.4 currently has nasty bugs)
Make sure the bullets and players are effectively in the wanted layer
The change in layer takes some time to take effect (few frames), since bullet are fast, you are probably encurring in that lag (so in the time the change take effect the bullet already hitted the target)
The best way is to have a Bullet Prefab that is spawned already in the correct layer, you can later customize that by changin graphics at runtime if you like, but to avoid the lag it should be instantiated already in the correct layer.
There is no need to go to physics manager, the OP already do the correct code equivalent to the physics manager. The real problem is that the GameObject should be already instantiated with the correct layer, because layer update may take some time to get effective.
Another workaround is to disable/reenable the collider.

How can I use compression forces in Unity3d?

I'd like to use compression forces to keep detached objects suspended in the air. Here's a photo of what I'm trying to accomplish:
Ideally, they would stay in the position illustrated above until acted upon by another force.
However, the boxes become all wonky and seemingly ignore the friction between each other.
If I put them closer together, they sort of explode in every direction, and if I put them exactly touching or further apart, they simply fall straight down.
Is this possible in Unity3d? or is this beyond the scope if the standard physics engine.
I haven't seen this implemented in any physics engine without intervention through code. Basically you'll have to make the objects immovable until some event triggers them to be movable.
There's no such thing as "compression force" in physics engines. The problem here is that even the slightest compression means two bodies are intersecting (overlapping) and any rigid-body physics engine will try to resolve that by moving the bodies out of the way.
A soft-body engine would be able to cope with that, but they're special use cases and not commonly used. For instance BeamNG.drive uses a soft-body physics engine to model the deformation of cars, and that's not ideal either as you'll sometimes notice that even strong metal connections have a slight wobble to them.
You can only model this behavior in a rigid-body physics engine if you were to attach the bodies through joints to keep them suspended in air, but even so they would either be allowed to intersect (might not look good unless intersection is minimal) or they'll start moving, possibly going wild. Or like I said at the beginning, have the bodies suspended at their position - put them to sleep, make sure once one of them wakes up they all wake up. Something like that.