- Home /
Destroy is not working with moving objects
Hi , I have a little problem here that I don't understand . You see , I have 3 type of platforms , one is standing still (not moving) , and other two are moving (one x direction, second y direction). I have a box collider , his job is to destroy an object if that object leaves the box . Box destroys that non-moving platform with no problems , but moving ones no. If I disable the movement from them , then box destroys them .
I can't understand why that is happening . Im using on those moving objects (it's the y one platform)
transform.Translate(-Vector2.up * Time.deltaTime * platYellowSpeed);
(basicly Im using transform.Translate to move platforms)
The tags are correct , my box (the one who destroys) has a simple destroy function (OnTriggerExit2D) , Box has a Trigger checked On , non-moving platforms and moving platforms have exactly same type collider2D with same options.
I ran out of ideas.. whats going on.. Oh And btw , I scripting on c# .
Objects that are moved via transform.Translate doesnt react with colliders.
Read more about Translate in documentation.
Answer by Maui-M · Feb 17, 2014 at 11:07 PM
Based off of what DajBuzi said, if transform.Translate doesn't react to colliders you could just destroy the objects when they go off screen.
transform.Translate(-Vector2.up * Time.deltaTime * platYellowSpeed);
if(transform.Position.y > 10.0f)
//destroy object
It would be better to check if his finger collides with collider:
Ray ray = camera.ScreenPointToRay(Input.GetTouch(i).position);
Your answer
Follow this Question
Related Questions
Creating and Moving objects 2 Answers
Destroy specific Objects 2 Answers
Right way of controlling objects in Scene? 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers