In Unity3D there's a way to add force at a position and a way to get the velocity at a position. I'd like to be able to set the velocity of a rigidbody2d at a local position.
My current solution which is very much WIP and very much wrong is as follows:
_colliderRigidbody.velocity = _knockbackForce; Vector2 dirToCenter = (_colliderRigidbody.position - Position2D).normalized; float relativeAngleVel = Vector3.Dot(dirToCenter.normalized, _knockbackForce.normalized); bool onRight = Vector3.Cross(dirToCenter, _knockbackForce).z > 0; relativeAngleVel = 1.0f - Mathf.Abs(relativeAngleVel); relativeAngleVel = onRight ? -relativeAngleVel : relativeAngleVel; _colliderRigidbody.angularVelocity = -relativeAngleVel * 50;//lol * 50 because who knows what I'm doing >.<
In regards to the problem I'm trying to solve: I have a 'bullet' which hits a target object, I know the point of impact and the direction the bullet is going so I'd like the velocity at that point of impact to be the same as the bullets.