I have an object that I can drag with mouse and I have a static wall which I can push with the object. I want to move the wall back when pressure reaches certain value
How can I do it?
I would spheretrace at the objects location, break the hit result, get hit distance.
And just check a bool if distance value is less than x float.
If you want different values then clampRange the distance to something like 0 - 100 (distance) in to 1000 - 0 (pressure) out.
That wouldnt work.
When the object is touching the wall, the distance is zero. if the pressure is applied, the distance doesnt change anymore.
That would require moving the object into the wall to “apply pressure”.
You could however give the wall two states: A: Idle and B: Pushing.
In the idle state the wall does nothing. Its the default state.
When the object touches the wall it starts moving the wall along with itself (as if zerof pressure is needed to move it).
The object also switches the wall into pushing mode.
The pushing mode does the following:
On tick it saves its current position and the position of the pushing object. Then it compares its position with the previos position. If that delta change is below a certain threshold, move both, the object and wall back to its previous position.
When the object untouches, the wall should stop ticking, a.k.a. Idle mode.
This way you have to push “fast”, which is equivalent of using force/pressure.
If you want to do something like a snap feature, then just store the mouse position on contact and build the delta from there.
I don’t think it would work in my case. And my question is not clear, “wall” is a skeletal mesh (because I need to use phat), with constraint, limited linear movement and motor with high strength. When object (also simulating physics) touches the wall I want decreasing motor strength depending on pressure
If you “need” to use phat and all of that there isn’t much I can suggest.
However you can still cheat it by moving the actor position when the wall intersects the cube manually.
and you can easily keep the axis back in place with a timeline. It wont/shouldn’t affect the PHat, the motor or anything else either technically speaking.