I’m very new to this so sorry if this is something really easy but my searches aren’t finding any answers.
I need the player to be able to grab and move/throw some objects and those objects need collision and physics enabled. I want to be able to gate it by a strength stat, which doesn’t work if the player can just push the object by walking into it. This is the most complicated thing I’ve tried:
Despite my attempt to make sure the object is at rest before disabling physics, the object still stops in midair if you touch it
Once physics is disabled, something needs to collide with it twice before it moves again (e.g. the first shot of the ball in the first person template only enables physics again, the second shot actually pushes the object)
I also tried making the object ridiculously heavy but it was still easy to knock over a cylinder by jumping on it and then roll it around, and even if it worked, it could cause issues I don’t know about yet.
Setting the CharacterMovement’s push force to 0 mostly stops me from rolling it around but I can still knock it over by jumping on it, and I might want the player to be able to push some things anyway.
That’s a tricky one. Can you maybe set the objects constraints to lock x, y, and z movement and rotation until it’s picked up? I have tried to do something like that myself, but I’m not sure if you can control those constraints via a blueprint.
I kind of figured out the solution to problem 1. I wasn’t getting the velocity or position correctly due to the mesh not being the root of the actor. For a moment I had my cylinder flying through the air keeping up-to-date info on its position and velocity in my UI, but now it’s messed up again and I don’t even know what I did to change it.
I had to switch from OnComponentHit to just Hit to get the hits from the balls to register at all (only way I can tell is I have it printing “Enabled physics”) but they still aren’t pushing the thing around like they used to.
Edit: Also, now that I get the velocity correctly it still keeps physics enabled because the thing has already started moving from me bumping into it before the event fires, apparently.
I just deleted the Hit event and then undid that and now pushing it with the balls is working again.
Some of the unexpected behaviour was caused by the instance of the blueprint I was testing on having a capsule collision component from before I started working on this stuff. The balls were colliding with that instead of the mesh.
I’m still not sure why there were times where I could move the object from rest by bumping into it, but it stopped doing that before I removed the component for some reason anyway.
To solve problem 2 (the rest of the answer to 1 is in my comment): in the projectile I save the impulse and location to variables at the moment of impact and apply it after a delay of 0.0001 if physics aren’t enabled already.
By that time physics simulation is enabled on the target, if it should be.