Hello, i’m new to the community so I wasn’t sure if this was the right place to post this. Sorry if it is not.
I have been following this tutorial on making an angrybirds like game and i noticed it is designed for a previous version. Although I was able to adapt some of my code to the new version, the end result was rather disappointing… There are some sections of the code that just wont work, particularly the section that destroys the spring to release the projectile. Here are some of the problems I had:
1-Projectile wont launch
In the tutorial the tutor wrote this code line:
(…)
if (!Rigidbody2D.IsKnematic && prevVelocity.sqrMagnitude > GetComponent().velocity.sqrMagnitude)
{
Destroy(spring);
}
(…)
However since now the Kinematic option of the RigidBiddy2D component is not a boolean this comparison isnt possible, even using the code adaptation:
(…)
if (!RigidbodyType2D.Knematic && prevVelocity.sqrMagnitude > GetComponent().velocity.sqrMagnitude)
{
Destroy(spring);
}
(…)
2-The Back Rubber band wont set properly
The rubber bands should update using the code
(…)
Vector2 catapultToProjectile = transform.position - catapultLineFront.transform.position;
leftCatapultToProjectile.direction = catapultToProjectile;
Vector3 holdPoint = leftCatapultToProjectile.GetPoint(catapultToProjectile.magnitude + circleRadius);
catapultLineFront.SetPosition(1, holdPoint);
catapultLineBack.SetPosition(1, holdPoint);
(…)
But the console gives the message “LineRenderer.SetPosition index out of bounds!” and only the back rubber band wont set. Since the index is 1 for both i don’t understand my error.
sorry again if this is not the correct place to post this. If anyone wants to help i would be glad to send my code and some screenshots, I would appreciate anyone that can help translate this code to the new version of the engine.