I’m trying to create the idea of a tethered sphere. I have a simple scene with 3 spheres in a box (floor plane and four surrounding wall planes). One sphere is the Player and has a rigidbody component attached. The other two spheres are “tethered” to their positions, but in a way that allows them to “move out of the way” or give-way when the player collides with them, after which they ease back into their initial/target position.
I’m not good enough with physics, to know how to set this up. Does anyone have some pseudo-code for the process or steps for the script?
Here’s what I’m currently testing, and it seems to be doing nothing; though I suspect I’ve got conflicting forces happening here.
protected void Update() {
//increment timer once per frame
currentLerpTime += Time.deltaTime;
if (currentLerpTime > lerpTime) {
currentLerpTime = lerpTime;
}
//lerp back into position!
float perc = currentLerpTime / lerpTime;
transform.position = Vector3.Lerp(startPos, endPos, perc);
}
void OnTriggerEnter(Collider other) {
Debug.Log ("Trigger some movement!!");
_thrust = 20f;
_rb.AddForce(0,0, _thrust, ForceMode.Impulse);
}