|
for example we have a variable v1: Vector3; when a collision happens we want to increase the vector3's x by 100 ! is there a way to do that ? thanks
(comments are locked)
|
|
You can modify the x/y/z of a Vector3 as follows.
If you want it to happen when objects collide, you can use OnCollisionEnter or OnTriggerEnter, depending on the rest of your setup. thanks that is what i was searching for!
Sep 26 '10 at 09:22 AM
anthony
Comment back on my answer if you have any troubles with the implementation and I'll help out where I can. :)
Sep 26 '10 at 09:35 AM
Marowi
i think i have a problem! if(collisionInfo.gameObject.tag == "player1") { velocity.x = velocity.x* 10000; } if(collisionInfo.gameObject.tag == "player2") { velocity.x = velocity.x* -10000; } but the velocity is still not changing! In the inspector it is still 0! do you have any idea why?
Sep 26 '10 at 09:44 AM
anthony
Multiplying 0 by 10000 will result in 0! Maybe add a "Debug.Log()" line in there to be sure that your ifchecks are working?
Sep 26 '10 at 09:55 AM
Marowi
you were right the if was not working but im not sure what im doing wrong... function OnTriggerEnter(collisionInfo : Collider) { if(collisionInfo.gameObject.tag == "player1") { print("HELLO"); velocity.x = (velocity.x+1)* -100; } if(collisionInfo.gameObject.tag == "player2") { print("HELLO"); velocity.x = (velocity.x+1)* 100; } } the hello is not showing! although im sure my script is right! do u have any idea?
Sep 26 '10 at 02:14 PM
anthony
(comments are locked)
|
