I was following tutorial
http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/making-angry-birds-style-game?playlist=17093 and in script i have like 10 erros and he doesnt.
Can you pls help me with my script ?
using UnityEngine;
using System.Collections;
public class ProjectileDraging : MonoBehaviour {
public float MaxStreach = 3f;
public LineRenderer CatapultLineFront;
public LineRenderer CatapultLineBack;
private Transform catapult;
private SpringJoint2D spring;
private Ray rayToMouse;
private Ray leftcatapultToProjectile;
private float maxStreachsqr;
private float circleRadius;
private bool clickedOn;
private Vector2 prevVelocity;
void Awake()
{
spring = GetComponent<SpringJoint2D>();
catapult = spring.connectedBody.transform;
}
void Start ()
{
LineRendererSetUp();
rayToMouse = new Ray(catapult.position, Vector3.zero);
leftcatapultToProjectile = new Ray(CatapultLineFront.transform.position, Vector3.zero);
maxStreachsqr = MaxStreach * MaxStreach;
CircleCollider2D circle = collider2D as CircleCollider2D;
circleRadius = circle.radius;
}
void Update ()
{
if (clickedOn)
Dragging = true;
if(spring != null)
{
if (!rigidbody2D.isKinematic && prevVelocity.sqrMagnitude > rigidbody2D.velocity.sqrMagnitude)
{
Destroy(spring);
rigidbody2D.velocity = prevVelocity;
}
if (!clickedOn)
{
prevVelocity = rigidbody2D.velocity;
}
LineRendererUpdate();
}
else
{
CatapultLineBack.enabled = false;
CatapultLineFront.enabled = false;
}
}
void LineRendererSetUp()
{
CatapultLineFront.SetPosition(0, CatapultLineFront.transform.position);
CatapultLineBack.SetPosition(0, CatapultLineBack.transform.position);
CatapultLineFront.sortingLayerName = "Foerground";
CatapultLineBack.sortingLayerName = "Foerground";
CatapultLineFront.sortingOrder = 3;
CatapultLineBack.sortingOrder = 1;
}
void OnMouseDown()
{
spring.enable = false;
clickedOn = true;
}
void OnMouseUp()
{
spring.enable = true;
rigidbody2D.isKinematic = false;
clickedOn = false;
}
void Dragging()
{
Vector3 mouseWorldPoint = Camera.main.ScreenToViewportPoint(Input.mousePosition);
Vector2 catapultToMouse = mouseWorldPoint - catapult.position;
if (catapultToMouse.sqrMagnitude > maxStreachsqr)
{
rayToMouse.direction = catapultToMouse;
mouseWorldPoint = rayToMouse.GetPoint(MaxStreach);
}
mouseWorldPoint.z = 0f;
transform.position = mouseWorldPoint;
}
void LineRendererUpdate()
{
Vector2 catapultToProjectile = transform.position - CatapultLineFront.transform.position;
leftcatapultToProjectile.direction = catapultToProjectile;
Vector3 HoldPonint = leftcatapultToProjectile.GetPoint(catapultToProjectile.magnitude + circleRadius);
CatapultLineFront.SetPosition(1, HoldPonint);
CatapultLineBack.SetPosition(1, HoldPonint);
}
}
Severity Code Description Project File Line
Error CS1656 Cannot assign to 'Dragging' because it is a 'method group' AngryBirdLikeGame.CSharp C:\Users\Jordan\Documents\AngryBirdLikeGame\Assets\Scripts\ProjectileDraging.cs 35
Severity Code Description Project File Line
Error CS1061 'SpringJoint2D' does not contain a definition for 'enable' and no extension method 'enable' accepting a first argument of type 'SpringJoint2D' could be found (are you missing a using directive or an assembly reference?) AngryBirdLikeGame.CSharp C:\Users\Jordan\Documents\AngryBirdLikeGame\Assets\Scripts\ProjectileDraging.cs 72
Severity Code Description Project File Line
Error CS1061 'SpringJoint2D' does not contain a definition for 'enable' and no extension method 'enable' accepting a first argument of type 'SpringJoint2D' could be found (are you missing a using directive or an assembly reference?) AngryBirdLikeGame.CSharp C:\Users\Jordan\Documents\AngryBirdLikeGame\Assets\Scripts\ProjectileDraging.cs 78
Severity Code Description Project File Line
Error CS0619 'Component.rigidbody2D' is obsolete: 'Property rigidbody2D has been deprecated. Use GetComponent<Rigidbody2D>() instead. (UnityUpgradable)' AngryBirdLikeGame.CSharp C:\Users\Jordan\Documents\AngryBirdLikeGame\Assets\Scripts\ProjectileDraging.cs 38
Severity Code Description Project File Line
Error CS0619 'Component.rigidbody2D' is obsolete: 'Property rigidbody2D has been deprecated. Use GetComponent<Rigidbody2D>() instead. (UnityUpgradable)' AngryBirdLikeGame.CSharp C:\Users\Jordan\Documents\AngryBirdLikeGame\Assets\Scripts\ProjectileDraging.cs 38
Severity Code Description Project File Line
Error CS0619 'Component.rigidbody2D' is obsolete: 'Property rigidbody2D has been deprecated. Use GetComponent<Rigidbody2D>() instead. (UnityUpgradable)' AngryBirdLikeGame.CSharp C:\Users\Jordan\Documents\AngryBirdLikeGame\Assets\Scripts\ProjectileDraging.cs 41
Severity Code Description Project File Line
Error CS0619 'Component.rigidbody2D' is obsolete: 'Property rigidbody2D has been deprecated. Use GetComponent<Rigidbody2D>() instead. (UnityUpgradable)' AngryBirdLikeGame.CSharp C:\Users\Jordan\Documents\AngryBirdLikeGame\Assets\Scripts\ProjectileDraging.cs 46
Severity Code Description Project File Line
Error CS0619 'Component.rigidbody2D' is obsolete: 'Property rigidbody2D has been deprecated. Use GetComponent<Rigidbody2D>() instead. (UnityUpgradable)' AngryBirdLikeGame.CSharp C:\Users\Jordan\Documents\AngryBirdLikeGame\Assets\Scripts\ProjectileDraging.cs 79
Severity Code Description Project File Line
Error CS0619 'Component.collider2D' is obsolete: 'Property collider2D has been deprecated. Use GetComponent<Collider2D>() instead. (UnityUpgradable)' AngryBirdLikeGame.CSharp C:\Users\Jordan\Documents\AngryBirdLikeGame\Assets\Scripts\ProjectileDraging.cs 28
Severity Code Description Project File Line
Error CS1061 'Component' does not contain a definition for 'velocity' and no extension method 'velocity' accepting a first argument of type 'Component' could be found (are you missing a using directive or an assembly reference?) AngryBirdLikeGame.CSharp C:\Users\Jordan\Documents\AngryBirdLikeGame\Assets\Scripts\ProjectileDraging.cs 38
Severity Code Description Project File Line
Error CS1061 'Component' does not contain a definition for 'velocity' and no extension method 'velocity' accepting a first argument of type 'Component' could be found (are you missing a using directive or an assembly reference?) AngryBirdLikeGame.CSharp C:\Users\Jordan\Documents\AngryBirdLikeGame\Assets\Scripts\ProjectileDraging.cs 41
Severity Code Description Project File Line
Error CS1061 'Component' does not contain a definition for 'velocity' and no extension method 'velocity' accepting a first argument of type 'Component' could be found (are you missing a using directive or an assembly reference?) AngryBirdLikeGame.CSharp C:\Users\Jordan\Documents\AngryBirdLikeGame\Assets\Scripts\ProjectileDraging.cs 46
Severity Code Description Project File Line
Error CS1061 'Component' does not contain a definition for 'isKinematic' and no extension method 'isKinematic' accepting a first argument of type 'Component' could be found (are you missing a using directive or an assembly reference?) AngryBirdLikeGame.CSharp C:\Users\Jordan\Documents\AngryBirdLikeGame\Assets\Scripts\ProjectileDraging.cs 38
Severity Code Description Project File Line
Error CS1061 'Component' does not contain a definition for 'isKinematic' and no extension method 'isKinematic' accepting a first argument of type 'Component' could be found (are you missing a using directive or an assembly reference?) AngryBirdLikeGame.CSharp C:\Users\Jordan\Documents\AngryBirdLikeGame\Assets\Scripts\ProjectileDraging.cs 79