I am working through the tutorials to increase my level of knowledge of unity, but I am running into issue on some of them saying "the project contains scripts that use obsolete API. When I do they update the script doesn’t function. Can someone look at this code and help me out?
before update API:
using UnityEngine;
using System.Collections;
public class Resetter : MonoBehaviour {
public Rigidbody2D projectile;
public float resetSpeed = 0.025f;
private float resetSpeedSqr;
private SpringJoint2D spring;
void Start () {
resetSpeedSqr = resetSpeed * resetSpeed;
spring = projectile.GetComponent <SpringJoint2D>();
}
void Update () {
if(Input.GetKeyDown (KeyCode.R)) {
Reset();
}
if(spring == null && projectile.velocity.sqrMagnitude < resetSpeedSqr){
Reset();
}
}
void OntriggerExit2D (Collider2D other){
if (other.rigidbody2D == projectile){
Reset();
}
}
void Reset () {
Application.LoadLevel (Application.loadedLevel);
}
}
After API update
using UnityEngine;
using System.Collections;
public class Resetter : MonoBehaviour {
public Rigidbody2D projectile;
public float resetSpeed = 0.025f;
private float resetSpeedSqr;
private SpringJoint2D spring;
void Start () {
resetSpeedSqr = resetSpeed * resetSpeed;
spring = projectile.GetComponent <SpringJoint2D>();
}
void Update () {
if(Input.GetKeyDown (KeyCode.R)) {
Reset();
}
if(spring == null && projectile.velocity.sqrMagnitude < resetSpeedSqr){
Reset();
}
}
void OntriggerExit2D (Collider2D other){
if (other.GetComponent<Rigidbody2D>() == projectile){
Reset();
}
}
void Reset () {
Application.LoadLevel (Application.loadedLevel);
}
}