UltraFlow Clone
For those who have tested and liked the game UltraFlow, I wanna show a little project which I did recently so as to increase my understanding about some physics on Unity 5. These scripts allow me to generate some sprites with behavior so as to create all obstacles and more. For the physics on the bullet, I use a drag&drop script. This way the project works fine on mobile device and WebPlayer. It’s an alpha, but you can see the first steps on screen. I think that it’s good enough. Try it if you want. See you later for the next Ludum Dare session…
I would like to know your point of view ++
When the bullet is blocked near of a corner, you can attract it to the center by using the C key :
void Update() {
#if UNITY_STANDALONE || UNITY_WEBPLAYER
// enables/disables the epicenter force field so as to attract bullet to the screen center
if (Input.GetKeyDown (KeyCode.C)){
if (_epicenter == false)
_epicenter = true;
else
_epicenter = false;
}
#endif
// point base so as to define where is the bullet
Vector3 viewPos = _camera.WorldToViewportPoint(target.position);
var vm = target.gameObject.GetComponent<Rigidbody2D>().velocity.magnitude;;
// limits velocity – more or less
if (vm >= 5.0f)
vm = 5.0f;
if (vm <= 2.0f)
vm = 2.0f;
// adds a force on the bullet so as to create a force field
if (_epicenter){
if (viewPos.x > 0.5f)
target.gameObject.GetComponent<Rigidbody2D>().AddForce(-Vector2.right * vm);
if (viewPos.x < 0.5f)
target.gameObject.GetComponent<Rigidbody2D>().AddForce(Vector2.right * vm);
if (viewPos.y > 0.5f)
target.gameObject.GetComponent<Rigidbody2D>().AddForce(-Vector2.up * vm);
if (viewPos.y < 0.5f)
target.gameObject.GetComponent<Rigidbody2D>().AddForce(Vector2.up * vm);
}
}
