Hi Everyone,
Been working on this for a few days now. How do I properly put a physics object SM like a bottle for example inside a shopping cart without the bottle bouncing around, and ejecting itself, as soon as the player starts pushing the cart?
It’s all about damping. To solve this in our current game (we have small physics objects in animating drawers) I set the objects linear and angular damping to a number that gave me results I was happy with. However if you are moving the the trolley quickly over a large distance this will probably not work as well for you.
I would suggest looking at Physical Materials. You could fake the physicality of the trolley and give it very low friction and restitution, which prevents objects from sliding or bouncing off that material, then overriding the combine modes to use the min value.
The other thing you could look into is the mass of the objects, even if that means changing it when putting the object into the trolley (I’m assuming that objects are placed in the trolley?)
Physics is hard, especially interacting objects with each other, I’ve always solved it through trial and error and never found a one size fits all solution.
Hi there !
There are multiple solutions to this problem and design is depends on the end feeling you want to achieve.
1- You can just attach object to cart. After placing the object you can detect and attach to cart socket or actor itself so they maintain position. Also you can use physics constrains to maintain a wobble motion still in the cart even.
2- When objects are inside the cart their physics properties changed, like weight, friction also damping. Damping would be quite important in that terms.
3- You can use mix of match of methods, an experimental method would be (depending on the game) use an invisible physics field on top section of the cart that pushes physics objects back into cart. A good phsyics material change and field addition on cart velocity > 0 would achieve quite nice results while still maintaining phsyics inside the cart.
I am assuming you are not using movement on physics so it shouldn’t add unwanted physics bugs.
Thank you so much for the replies. I guess I am trying to achieve more like how the game storage hunter achieves moving physics Objects. The objects are placed in a truck, can move around when initially placed, and then freeze in place before the character gets in and starts driving the truck so the objects don’t fall out. Then the objects can be grabbed again, and physics is enabled again, allowing the objects to do interact as a normal physics object would. @Ruffhaus @RedGrimnir
Okay in that case I would approach it like this, this is not the only way but this should give you the results you’re after.
When you place the object into the trolley you should set its Damping to a level that works (the numbers below are rough and will need to be experimented with). You then add it to an array with all the other objects in the trolley (In this example I am assuming you have a bunch of objects in the trolley already).
Then when the trolley begins movement we set all the objects in it to no longer simulate physics and attach them all to the trolley itself. This will lock them into their world position relative to the trolley so as it moves they will move with it and maintain that relative location.
Then when the trolley stops we can detach all the objects from being parented and turn their physics back on. (Note that you don’t necessarily have to do this here and could wait until you pick up the item and only turn its physics back on but this will bring the trolley back to being in a live state with all the objects interacting with each other.)
Then when you want to grab an item again you set the damping of that mesh back to default and remove it from the array of objects that are in the trolley.
So that should work, but as I said earlier this is just one way to do it and your mileage may vary depending on a few factors (number of physics actors colliding with each other is a big one) but I think as a starting point that will get you what you want.
Thank you so much for this detailed explanation. We will give it a go today and I will let you know how it works out. I sincerely appreciate the time to give the response.
We are very new to unreal, so we are struggling how to grab a reference to the bottle to change it’s damping from inside the carts blueprints. What would be the best way to do that?