- Home /
Click on button to move?
Hello,
I have to 2 questions:-
1-I am making android game and i want to make cube(button) when player click on it an object(Bullet) move
void a(){ transform.translate (0,4,0); }
i used this c# code and attach cube with object but it failed
2- How to Make the bullet faster over time?
thanks,
Do you mean "click" or "tap", or both? You should use On$$anonymous$$ouseDown for clicks, and Input.Touches for taps. Excellent example here. Unity Touch Example.
Or, (shameless plug here), you could use Visual Actions and be done with it.
Having said that, you should write post separate questions in separate threads.
Answer by bubzy · Aug 18, 2013 at 07:35 AM
you aren't really changing anything here.
void a() //by the way this is a kinda crappy function name, will you remember its purpose in 6 months time?
{
transform.position += new Vector3(0,4,0);
}
your second question doesn't make a lot of sense,
but if you want to move something based on time you can use
float timeToSpeedUp = 2.0f; //every 2 seconds
float currentDelay = 0;
float speed = 0.3f;
void Start()
{
currentDelay = Time.time + timeToSpeedUp;
}
void moveBullet()
{
transform.position += new Vector3(0,Time.deltaTime * speed,0); //this will obviously only move the object on the Y axis, you can change that by the position that you put the "Time.deltaTime * speed" code in within the Vector3
//you can also increment or decrement the speed of this object by adjusting the value stored in the "speed" variable.
if (Time.time > currentDelay)
{
speed += 0.1f; // change this to the increment you want
currentDelay = Time.time + timeToSpeedUp;
}
}
thanks for your reply,
I have changed the question no 2 as i write it wrong,
in this question i want to know
How to $$anonymous$$ake the ball faster over time?
Your answer
Follow this Question
Related Questions
using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers
Move Rigidbody along curve 1 Answer
help with gameObject.translate 1 Answer
Get inventory of gameobject 0 Answers
How to Place a Game Object in game(Place a building) 0 Answers