- Home /
Colliding problems.
Hello everyone. I need to write a script which adds value of 2 to wood_left variable when axe collides with the tree. Okay, so I have a player and axe is child of player so they move together. But I got a little problem. Player does collide with the tree, but axe doesnt. Axe is a group of two parts what makes axe and both of these parts have mesh colliders on. But they just wont collide have no idea why. I`m sorry its just to hard to explain, I just cant. So could someone please (I hate when people ask for scripts while they give nothing, but I`m just gonna shoot myself I`m so confused) help me write this script, or give a short summary how it should look like. Oh and I forgot to mention I have tried putting the script on the player, it collides but it wont add 2+ to the Wood_left variable, I`ve changed the script to OnTriggerEnter instead of OnCollisionEnter and works fine except it walks through the tree.
So okay heres what I need: If axe touches the tree +2 is added to the wood_left variable and for them to collide not just ghost each other.
ANY help will be appreciated. :( :p
P.S. Sorry for the tags, the tag system is stupid it wont let me create my own tags but I HAVE TO add tags so how da should I know what tags have been used already by other people, It does gives suggestions but my suggestions were: vector 2 and samsung galaxy tab 2 so I choose vector 2... Sorry again. :)
You can't really collide two mesh colliders. Also, add a rigidbody.
BTW you can add whatever tags you like :)
Ive changed axe to box colliders and its still aint workin
I have tried putting the script on the player, it collides but it wont add 2+ to the Wood_left variable
Go with this one. The adding +2 is easier to work out.
At first I`ve somehow fixed that value of 2 is added to the Wood_left variable when only axe and no other collider touches it, but it still was going through it. After few more hours of playing with it, I have finally made that both of them actually collide, but now wood_left wont update. What the actual ... please help :)
Answer by henris08 · Apr 27, 2014 at 08:00 PM
Oh and another problem:
Axe is group of 2 objects && its a child of GameObject Player. Its obviuosly childed by Player only so they can move together without any scripting. Okay so let me explain whats the problem: Imagine: - is the grass/terrain whatever. T - is the tree. P - is the player. A - is the axe.
Edit:Picture added instead of text because it gets distorted after posting. ** I know I know I could have added real ''game'' pictures, but I dont have unity on this pc so sorry about that. Also anyway I hope u understood it. :)
For things like this, I have a script that sets the position of heldObject (i.e. the axe)to the players position plus Vector3.Forward This makes it so the axe is held infront of the player at all times, the problem is the axe can pass through things unless you script something else, or you could increase the size of the player's collider and then just make the tip of the axe a trigger.
Your answer
Follow this Question
Related Questions
Mesh Collider STOPPING Objects Instead of Detecting Collision 1 Answer
Problems with collisions while rotating a rigidbody 1 Answer
Mesh collider not colliding with ball properly 1 Answer
Anyway to make my object not fall through the floor without convex? 0 Answers
NavMesh Collision Detection? 0 Answers