Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
998 B
1
Indexable
Never
if(true)
{
	Vector3 velocity = Rigidbody.velocity;
	Vector3 raycastDirection = transform.TransformDirection(-Vector3.up);
	Vector3 digerVelocity = Vector3.zero;
	Rigidbody raycastHitRigidbody = RaycastHit.rigidbody;
	if (raycastHitRigidbody != null)
		digerVelocity = raycastHitRigidbody.velocity;
	float raycastDirectionVelocity = Vector3.Dot(raycastDirection, velocity);
	float digerDirectionVelocity = Vector3.Dot(raycastDirection, digerVelocity);
	float relativeVelocity = raycastDirectionVelocity - digerDirectionVelocity;
	float x = RaycastHit.distance degeri - float vibrasyonHeight;
	float springForce = (x * float vibrasyonSpringStrength) - (relativeVelocity * vibrasyonSpringDamper);
	Debug.DrawLine(transform.position, transform.position + (raycastDirection * springForce), Color.yellow);
	Rigidbody.AddForce(raycastDirection * springForce);
	if (raycastHitRigidbody != null)
		raycastHitRigidbody.AddForceAtPosition(raycastDirection * -springForce, RaycastHit.point);
}