- Home /
This question was
closed Nov 19, 2014 at 05:41 PM by
Graham-Dunnett for the following reason:
Duplicate Question
Question by
Hazarcelen2 · Nov 19, 2014 at 05:39 PM ·
c#animationanimatornullreferenceexceptionwarning
NullReferenceException: Object reference not set to an instance of an object
Hey guys i am newbie i try to mak character controller and i use this video but my code does not working and here is my code warning NullReferenceException: Object reference not set to an instance of an object NewPlayer.FixedUpdate () (at Assets/Codes/NewPlayer.cs:15) and this is my code
using UnityEngine;
using UnityEngineInternal;
using System.Collections;
public class NewPlayer : MonoBehaviour {
public float maxSpeed = .10f;
bool _sagaBakma = true;
Animator animasyon;
void start()
{
animasyon = GetComponent<Animator> ();
}
void FixedUpdate(){
float hareket = Input.GetAxis ("Horizontal");
animasyon.SetFloat ("Speed", Mathf.Abs (hareket));
rigidbody2D.velocity = new Vector2 (hareket * maxSpeed, rigidbody2D.velocity.y);
if (hareket > 0 && !_sagaBakma)
Flip ();
else if (hareket < 0 && _sagaBakma)
Flip ();
}
void Flip(){
_sagaBakma = !_sagaBakma;
Vector3 _deger = transform.localScale;
_deger.x *= -1;
transform.localScale = _deger;
}
}
tyvm for helping by the warning at animasyon.SetFloat("Speed",MathfAbs(hareket));
Comment
Follow this Question
Related Questions
Conflicting Animator SetTrigger 0 Answers
pause Animation 0 Answers
Is it possible to always make animations play differently? 0 Answers
Animator not showing animation 1 Answer