Can someone help me ?
I have a circle and i want to jump when i click on it ....please help i am new at this :'(
my code is :
using UnityEngine;
public class flapcontroller : MonoBehaviour {
public float flapSpeed = 100f;
private Rigidbody2D rigidbody;
private bool didFlap;
public void Start ()
{
this.rigidbody = this.GetComponent<Rigidbody2D> ();
}
public void Update ()
{
if (Input.GetButtonDown ("Fire1"))
{
this.didFlap = true;
}
}
public void FixedUpdate()
{
if (didFlap)
{
didFlap = false;
this.rigidbody.AddForce (new Vector2 (0, flapSpeed));
}
}
}
my code is :
using UnityEngine;
public class flapcontroller : $$anonymous$$onoBehaviour { public float flapSpeed = 100f; private Rigidbody2D rigidbody; private bool didFlap;
public void Start ()
{
this.rigidbody = this.GetComponent<Rigidbody2D> ();
}
public void Update ()
{
if (Input.GetButtonDown ("Fire1"))
{
this.didFlap = true;
}
}
public void FixedUpdate()
{
if (didFlap)
{
didFlap = false;
this.rigidbody.AddForce (new Vector2 (0, flapSpeed));
}
}
}
Answer by Firedan1176 · Dec 25, 2015 at 10:25 PM
this.rigidbody.AddForce (new Vector2(0, flapSpeed), ForceMode2D.Impulse);
Answer by rocky111418 · Dec 29, 2015 at 09:18 AM
It doesn't work ... :'( something is missing. I don't know what, quote: The referenced script on this Behaviour (Game Object 'circle1') is missing! Pleas helpp !!!
Your answer
Follow this Question
Related Questions
Unity is reseting Dictionary when game is playing 0 Answers
[Solved] How to Script a Camera That Follows the Player but Collides with the Edge of the Level 2 Answers
localscale not working 1 Answer
Camera Jitters When Displacing and Rotating Smoothly 0 Answers
My sprite disappears from the camera view after some time moving 5 Answers