# mamanybono

Member

5

1. ## Applying force to an object. (Unity)

I am suspecting about this, do you think, is it possible? When my problem occurs, unity consol shows "Wright wall hit" then "Shoot" in this case, first wall applies force to ball on left direction, then uparrowe codes eliminate all forces and gives a forward force. But ball is moving to left side. I think unity first reading codes for collision of right cube and shows the "Right wall hit", then it applies the force to left direction. If ? push the uparrow button, while collision of right cube is occuring, system gives priority to my uparrow button and it is freezing the collision of right cube just after console writes "Right wall hit", then uparrow codes works, they eliminate all forces and gives just forward direction force, after uparrow codes finish, right cube collision continue and it applies to force on left direction.
2. ## Unity Applying force to an object. (Unity)

Hi every body. I have a problem about applying force to an object. My scene is this. There is two cube on the scene and they have distance  between them. At the middele o f these 2 cuve there is a sphere. When the game start as soon as sphere hit the plane the plane applying just  for 1 time a force to right. Then sphere hits the right cube and the cube applyes force to left, left cube applyes force to right, it goes in  this way. When player push the uparrow, I tried the eliminate all the forces on sphere and try to give force on forward direction. This codes are  working good but sometimes when player shoots the ball it doesnt eliminates all power, sphere goes to forward and right or forward and left.  What is the reason do you think.     Here is the video link maybe it helps to you for easier understanding. First shoot is okey for me but second one is fail. By the way for both shoots it says "SHOOT" at the console so it proves my codes in the uparrow case was worked.         Here is the code. public var first: int =1; public var firstshoot: int =1; function Start () { } function Update () { if(Input.GetKeyDown(KeyCode.UpArrow)) { firstshoot=0; rigidbody.velocity = Vector3.zero; rigidbody.angularVelocity = Vector3.zero;  rigidbody.AddForce(Vector3.forward * 3000); Debug.Log ("Shoot"); } } function OnCollisionEnter (thecollision : Collision){ if (thecollision.gameObject.name == "FinishLine"){ Application.LoadLevel (0); } if (thecollision.gameObject.name == "Plane" && first == 1){ Debug.Log ("Floor Hit"); rigidbody.AddForce(Vector3.right * 500); first=0; } if (thecollision.gameObject.name == "Cube1" && firstshoot == 1){ Debug.Log ("Right Wall Hit"); rigidbody.AddForce(Vector3.right * -3000); } if (thecollision.gameObject.name == "Cube2" && firstshoot == 1){ Debug.Log ("Left Wall Hit"); rigidbody.AddForce(Vector3.right * 3000); } }

4. ## Changing ball direction according to GUI object.

Hi everybody. I searched google but could not find something enough siple for me. Could you    please help me.   The case is this: There is a ball on scene and a kick button also there is a gui object    which is for determining the ball direction.   There is 120 level on gui object. The level is changing by time but I want it to be fast,    because user should not catch it easly. Cany we change the levels according to milisecond    for example per 2 milisecond 1 level.   After this, how can get the value of gu? object's value when I press the kick button and    give it to ball as a direction. Thanks a lot for your helps.   By the way, I am using javascript.