- Home /
how to put upward force using tap
hello..
iam new to unity and i just want to ask you about tapping,that if you tap the button the object will goes upward and then if i want to stop tapping the button it will go back to its original position...
we are trying toimplement a game just like water toss that you need to shoot the ring in the pole dat once you tap the ring it applied upward force inorder to shoot the ring to the pole..
i hope you can read this message asap.. we nid ur helppp.... thank you so muuuuch
Answer by lexen1 · Jan 11, 2014 at 04:59 PM
I had that problem just a couple of minutes ago. I solved it by adding:
if (Input.GetButtonDown ("Jump")) {
rigidbody.AddRelativeForce (Vector3.up * 1000);
}
to the void Update. That said, I am going about this in a strange way because of the way my game works.
Answer by Josenifftodd · Jan 11, 2014 at 06:52 AM
This might work not sure, I've just made my Mill (Blades) start rotating. This should make your camera rotate, use this to start working out which way it needs to rotate if you understand how Vector3 works. I'm not sure how to make it reset back to its set position you will have to work that one out I'm a nooob at coding.
var button: GameObject; // Attach a GUI.Tecture here
var camera: GameObject; // Attach your Camera Here in your inspector
var speed: int; // Speed of the camera moving upwards
var btnTexture : Texture;
function OnGUI() {
if (!btnTexture) {
Debug.LogError("Please assign a texture on the inspector");
return;
}
if (GUI.Button(btnTexture))
camera.transform.Rotate(-Vector3.forward * speed * Time.deltaTime);
Debug.Log("Clicked the button with an image");
else {
Debug.Log("You need to attach a reset script here. Not sure how to do this myself.")
}
thank you so much. it can help us..
do we need to create a button wherin every time we tap that button the ring will float towards the pole? beacause our game is purely underwater,the environment is underwater sir.
I'm not too sure about that I only really know how to make it rotate