# Controlling a variable of type Vector 3

 0 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 more ▼ asked Sep 26 '10 at 08:48 AM anthony 15 ● 3 ● 3 ● 6 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 You can modify the x/y/z of a Vector3 as follows. ``````var vectorOne : Vector3; vectorOne.x += 100; `````` If you want it to happen when objects collide, you can use OnCollisionEnter or OnTriggerEnter, depending on the rest of your setup. more ▼ answered Sep 26 '10 at 08:54 AM Marowi 4.9k ● 4 ● 14 ● 53 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 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email: