Question by
oussamahassini6 · May 22, 2018 at 04:43 PM ·
scripting problemgameobjecttriggerpositionprogramming
My gameobject stops moving after entering the trigger??
the arrow stops moving after entering the trigger. even if go =true. and the stop trigger is the big circle.!
public InsStart intstart; public Text scoreText; public Quaternion rot; // private int score; private int add; public float speed = 25f;
public GameObject Player;
public float speed1;
public GameObject test;
private Rigidbody2D rb;
public bool go;
public GameObject point;
// Use this for initialization
void Start()
{
intstart = GameObject.FindWithTag("papa").GetComponent<InsStart>();
go = false;
rb = GetComponent<Rigidbody2D>();
transform.position = new Vector2(0.0f, 3.41f);
}
// Update is called once per frame
void Update()
{
rot = point.transform.rotation;
if (intstart.instantiate == true)
{
Instantiate(point, test.transform.position,rot);
}
if (go==true)
{
transform.position += transform.up * Time.deltaTime * speed1;
return;
}
Vector2 dir = this.transform.position - Vector3.zero;
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg + 90;
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
transform.RotateAround(Vector2.zero, Vector3.back, speed * Time.deltaTime);
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "cibl")
{
Application.LoadLevel("scene");
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == "stop")
{
go = false;
}
}
private void OnTriggerExit2D(Collider2D col)
{
if (col.gameObject.tag == "pizza")
{
go = true;
add += 2;
scoreText.text = add.ToString();
}
if (col.gameObject.tag == "stop")
{
go = false;
}
}
public void Onclick()
{
if (go != true)
go = true;
}
}
capture-decran-160.png
(228.8 kB)
capture-decran-159.png
(186.0 kB)
Comment
Answer by MiracleWhip24 · Jun 07, 2018 at 01:02 PM
@oussamahassini6 What exactly are you trying to do? If I know what you're trying to do, I can help you much better.
Answer by coidevoid · Jun 07, 2018 at 01:41 PM
OnTriggerEnter2D(Collider2D other)
{
if(other.CompareTag("knife")
{
other.GetComponent<RigidBody2D>().velocity = Vector2.zero;
}
}
Maybe?
Your answer
Follow this Question
Related Questions
Detect overlapping objects 2D game 0 Answers
[Solved]Weird Time.timeScale behavior 3 Answers
Two colliders that trigger different things in the same object-hierarchy 0 Answers
Input Command Issues 0 Answers
Input Command Issues 0 Answers