- Home /
Question by
donico · Mar 02, 2021 at 09:49 AM ·
animationraycastingprocedural animation
Why is the second half my oval all jagged?
trying to make something like procedural animation by having my foot target spin around its parent and shoot a ray cast up to see if it hit something and get that point and its kinda working but not 100% it also doesnt work when it goes into colliders. this is the code that ive been using.
void Update()
{
float halfsize = size / steph;
transform.localPosition = new Vector2(0f + (size * MCos(alpha) * MCos(tilt)) - (halfsize * MSin(alpha) * MSin(tilt)),
0f + (size * MCos(alpha) * MSin(tilt)) + (halfsize * MSin(alpha) * MCos(tilt)));
alpha += speed;
checkheight();
}
float MCos(float value)
{
return Mathf.Cos(Mathf.Deg2Rad * value);
}
float MSin(float value)
{
return Mathf.Sin(Mathf.Deg2Rad * value);
}
public void checkheight()
{
RaycastHit _ray;
Debug.DrawRay(target.position, target.up * 3f, Color.blue);
if (Physics.Raycast(target.position, target.up, out _ray, 10, mask))
{
Debug.Log("foot hit" + _ray.collider.name);
target.position = _ray.point;
}else
{
target.position = transform.position;
}
}
footiknotworking.png
(56.8 kB)
Comment
Your answer
Follow this Question
Related Questions
How to fix click range & time delay on animated object 0 Answers
Playing animation for object if hit by player camera s ray 1 Answer
how to keep texture animations in sync 0 Answers
Having trouble with animation rigging of this spider 0 Answers
Raycast only works right next(practically on top of) object 0 Answers