Question by
darkerter · Apr 21, 2017 at 01:17 PM ·
programmingif-statementsif statementlogicvalues
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
Your answer
Follow this Question
Related Questions
how to make a succession(n+1,5n,etc) that work in if statement? 0 Answers
Rotating player around rotating planet,Rotation of player on a rotating planet 0 Answers
How to use or statements in an if statement. 1 Answer
If Time > 0.25s 1 Answer
I want to create a button to check if one skybox is enable and change it to another one. 0 Answers