running infinite
How to make my character to fly upwards without limit as for example game pou, subway that ran without limits
Answer by Ali-hatem · Oct 18, 2015 at 11:04 AM
//use Rigidbody.velocity if 2d Rigidbody2d.velocity and this script from my 2d game :
using UnityEngine;
using System.Collections;
public class Mover : MonoBehaviour
{
private float movspeed = 8f;
void FixedUpdate ()
{
rigidbody2D.velocity = new Vector2 (movspeed ,rigidbody2D.velocity.y); // in this line movspeed is the x value of the rigidbody and it will always go to the right in speed of 8.
}
}
Answer by lothlorientos · Oct 18, 2015 at 01:00 PM
I think the best way to do this is to make an "Object Pooling". What this basically means is that you have a spawner above the screen which will instantiate new objects at random, BUT what is coll with object pooling is that when the objects leaves under the screen it gets disabled, so that you can transform this same object again later on the spawner (Without instantiating a new object, so that you don't have too many instantiated objects getting your game slower and slower).
Search for object pooling and you shall find a lot of examples! Here are some links you can start looking:
http://jessefreeman.com/dev-diary/simple-pooling-gameobjects-unity/
https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/object-pooling
Your answer
Follow this Question
Related Questions
Running sounds repeat too often? 1 Answer
Question about running and terrain generation 0 Answers
Running in batchmode 0 Answers
Running unity in another application 2 Answers
How to sprint with the Standard Asset FPS Controller with a Controller/Gamepad 0 Answers