Question by
ChocoCheezits · Apr 14, 2021 at 10:40 PM ·
animationrectangle
How can I make a rectangle animate to extend towards a certain point?
Does anybody know how I can animate a rectangle in 3D to extend to a certain point? I'm trying to make a grappling hook for my project and the code I've used extends slightly past the intended point, which is very noticeable when it hits the edges of an object. Here's the code:
void HandleHookshotThrown()
{
hookshotVisual.LookAt(hookshotPosition);
float throwSpeed = 100f;
hookShotSize += throwSpeed * Time.deltaTime;
hookshotVisual.localScale = new Vector3(.8f, .8f, hookShotSize);
if (hookShotSize >= Vector3.Distance(transform.position, hookshotPosition))
{
state = State.HookShotFlying;
cameraFOV.SetCameraFOV(HookShot_FOV);
}
}
hookShotSize is declared outside the function.
hookShotPosition is the position of the location that a raycast hits
-the state is just an enum I set up
Thanks in advance for any help!
Comment
Your answer
Follow this Question
Related Questions
FPS Controller Auto Movement 0 Answers
How to get root motion from animations made in blender? 1 Answer
How to play animation 0 Answers
Can someone help me ? 0 Answers
Problems with using the same Animator Controller on multiple objects. 0 Answers