- Home /
Logic errors making an unity4 project in unity5
I'm very new with unity and this is my first complete project with scripting involved, I decided to follow this tutorial https://unity3d.com/es/learn/tutorials/modules/beginner/live-training-archive/making-angry-birds-style-game to make an angry birds style game but its oriented to Unity 4 and I'm using unity 5 so in lines of code like this one
if (!rigidbody2D.isKinematic && preVelocity.sqrMagnitude > rigidbody2D.velocity.sqrMagnitude) { Destroy(spring); rigidbody2D.velocity = preVelocity; }
I had to change it to GetComponent() as GameObject.rigidbody has been deprecated, so i chaged it to
if (!GetComponent().isKinematic && preVelocity.sqrMagnitude > GetComponent().velocity.sqrMagnitude) { Destroy(spring); GetComponent().velocity = preVelocity; }
but my game makes all kind of crazy stuff and I dont have any idea why. I follow the tutorial step by step and I only make changes in the scripting that used the rigigbody2D component so it should work right? please help
Answer by yashpal · May 16, 2015 at 05:52 AM
hello @baha_z,
you can make new variable and than assign it rigidbody component.
Rigidbody2D rigidbody2D = GetComponent<rigidbody2D>();
if (!rigidbody2D.isKinematic && preVelocity.sqrMagnitude > rigidbody2D.velocity.sqrMagnitude) { Destroy(spring); rigidbody2D.velocity = preVelocity; }
Your answer
Follow this Question
Related Questions
PlayerPrefs not saving on Android/iOS Phone but saving on Unity Editor 2 Answers
Trying to make my charcter walk on on wall in unity 4 with mecanim 0 Answers
Unityshader, upgrading from unity4 to unity5 error 0 Answers
Help! CRASH in Unity 4.1.2 where 3.5.6 works fine (ContactMessage::onContactNotify) 0 Answers
Upgrading from 4 to 5 0 Answers