이펙트아카데미 특강/외주/커뮤니티
So, here I am again my goal is to make guts fall from a zombie character I have laying around, and with it comes some squash and stretch guts and organs that fall out of it.
How am I going to do it? I have no clue. I guess you and me will find out!
Update -1
So to start off I watched a bunch of videos, messed around with a lot of shader things (rotate about axis) (could not get it to work) so I tried another method. this time I started from scratch.
So I came up with the idea to pass the collision point of the object into a space local to the object.
Something like this or similar, and I wanted to get the result of this
Which I somehow of a miracle made happen:
and with that comes the shader: although I could not get rotation to work it’s definitely a step in the right direction!
So today I managed to get rotation working, by simply changing two inputs and converting to world/object space! I am so blind!
Here is what the shader looks like now:
Code related:
private void Start()
{
rend = GetComponent<Renderer>();
RB = GetComponent<Rigidbody>();
}
private void Update()
{
rend.material.SetVector("_ContactPos", toPoint);
if (!colliding && collisionPoint != Vector3.zero)
{
spring2 = 0f;
spring += Time.deltaTime;
toPoint = Vector3.Lerp(collisionPoint, Vector3.zero, spring);
}
if (colliding)
{
spring2 += Time.deltaTime;
toPoint = Vector3.Lerp(toPoint, collisionPoint, spring2);
if (toPoint == collisionPoint) { spring2 = 0f; }
}
}
public void OnCollisionStay(Collision collision)
{
colliding = true;
ContactPoint contact = collision.GetContact(0);
point.position = contact.point;
collisionPoint = -point.gameObject.transform.localPosition;
Vector3 dir = transform.position - collisionPoint;
directionPoint = dir.magnitude;
}
public void OnCollisionExit(Collision collision)
{
spring = 0;
colliding = false;
}
}