Question by
darkerter · Apr 20, 2017 at 04:24 PM ·
programmingif-statementslogicvalues
how to make a succession(n+1,5n,etc) that work in if statement?
hi, I have a problem here, I want to make a succession (n+1,5n,etc) that when my variable scorepoint get in the multiple of 5 (5x1= 5,5x10= 50,etc) make that my sprite bounce in the box please i would like help.
using UnityEngine;
using System.Collections;
public class InteracionConRebounce : MonoBehaviour {
Collider2D co;
Rigidbody2D rb;
public int scorepoint;
public float poderDeFuerza;
// Use this for initialization
void Start ()
{
co = GetComponent<Collider2D> ();
rb = GetComponent<Rigidbody2D> ();
if
}
// Update is called once per frame
void Update ()
{
Vector3 mp = Camera.main.ScreenToWorldPoint(Input.mousePosition);
if (Input.GetMouseButtonDown (0))
{
if (co.OverlapPoint(mp))
{
if (scorepoint == 0)//here i want the succession
{
rb.AddForce(new Vector2(1000,0));
//here i want my sprite bounce
}
if (scorepoint > 0)
{
Debug.Log("dectetado2");
rb.gravityScale += 0.05f;
}
Debug.Log("dectetado");
rb.AddForce(new Vector2(0, poderDeFuerza));
scorepoint++;
}
}
}
}
here is all the code
Comment