Should’ve wrote it at the beginning of the journey but it’s never too late !
Journey’s still on so, consider this as writing from a moving car over bumpy road .
Idea is to describe in detail every major and interesting obstacle.
Mind you, had to be very patient searching, maybe 10th link would give me an idea.
I’ll try to present only final solutions and hope someone will find it valuable.
Should be lots of code examples and pics so enjoy following !
(MEM) My Enormous Mistakes – TOPPA chapter : Part I
1. Main object missing in build, some controls not working…
#if UNITY_ANDROID && !UNITY_EDITOR//uncheck keyboard if set, also, disable FX that jitter
IsKeyboard = false;
GameObject.Find(“FX”).SetActive(false);
#endif
Spent hours trying whatnot just to solve problem while doing my daily gym workout
– turned out I checked out FX GameObject thus not finding it in build and producing error .
That rendered whole script unusable !
Good job Unity…
(MEM) My Enlightening Moments – TOPPA chapter : Part I
yMin = GO_PEN.transform.position.y – camHeight; // lower bound
yMax = GO_PEN.transform.position.y + camHeight; // upper bound
…
void CheckInput()
{
float x;
float y;
xMax = cam.transform.position.x;//right bound
xMin = xMax – camWidth + 2f;//left bound
if (IsKeyboard)//Keyboard…else it’s touch controller
{
if (Input.GetKey(KeyCode.Q))
ver = 1;
if (Input.GetKey(KeyCode.A))
ver = -1;
if (Input.GetKey(KeyCode.O))
hor = -1;
if (Input.GetKey(KeyCode.P))
hor = 1;
if (Input.GetKeyDown(KeyCode.Comma))
Shoot();
if (Input.GetKeyDown(KeyCode.M))
Bomb();
}
direction = new Vector2(hor, ver/2);//split vertical speed
if (hor < 0)
{
direction.x *= sensitivity*moveSpeed * Time.deltaTime/40; // sync with hor scroll speed
direction.y *= sensitivity*moveSpeed * Time.deltaTime;
}
else
direction *= sensitivity*moveSpeed * Time.deltaTime; // apply speed
x = GO_PEN.transform.position.x;
y = GO_PEN.transform.position.y;
if (hor == 0 && ver == 0)
GO_PEN.GetComponent<Rigidbody2D>().velocity = new Vector2(6f,0);//keep up the position
else//it’s moving !
{
if (y > yMax && ver > 0 || y < yMin && ver < 0)
direction.y = 0;
if (x < xMax && x > xMin || x > xMax && hor < 0 || x < xMin && hor > 0)
GO_PEN.GetComponent<Rigidbody2D>().velocity = moveSpeed * direction * 3f;
else
if ((x > xMax || x < xMin) && ver != 0)
{
GO_PEN.GetComponent<Rigidbody2D>().velocity = new Vector2(6f,3f * moveSpeed * direction.y);
}
else
GO_PEN.GetComponent<Rigidbody2D>().velocity = new Vector2(6f,0);
}
if (IsKeyboard)//Keyboard
{
hor = 0;
ver = 0;
}
}