- Home /
How to attach the box collider to the object so that the collider moves with it?
I just started using unity this semester, and I am creating an octopus that spits ink and moves away (with an animation script) when the first person enters the box collider. I am new with scripting so I made 2 separate scripts for each action. (probably not a very efficient way)
1) one particle system with a box collider that produces ink when first player enters 2) an octopus, with a box collider, that moves away when first player enters I put the object and box colliders together at the same place so that both actions will happen when the first player enter the colliders
the problem is: the particle system and the 2 box colliders will stay there after the octopus has moved away. So every time the player goes to that area even when there is no octopus, the box colliders are triggered and ink will come out.
How can I attach the particle system and the box collider of the particle system and the octopus to the Octopus object, so they will move with the octopus?
Thanks!!
Take the octopus gameObject as parent in the hierarchy, and drag the other objects in to it so that they become the children and will move along with the octopus.
I have tried that, but it did not work. The Octopus is the parent, and the particle system is a chld.
Only a screenshot of the hierarchy and perhaps the different inspectors can give us an idea of what went wrong in that case.
Answer by StrainOfThought · Mar 27, 2013 at 11:58 PM
It should be possible to write this so that you have one single game object with one octopus mesh component, one particle system component, two script components, and one collider component that both the "move away" script and "spray ink script" respond to.
Even if that ends up being too complicated for you at this stage, Unitraxx's straightforward suggestion should still work. Has your class covered parenting transforms yet? It's a basic operation. If you're having trouble with it you may need to spend some more time just learning the interface.
Your answer
![](https://koobas.hobune.stream/wayback/20220613095226im_/https://answers.unity.com/themes/thub/images/avi.jpg)