Starting with Unity 3D software
During the last tutorial with Chris, we had narrowed down my way forward to two steps.
-
Continue with Adobe Animate even with the slow frame rate and lagging gameplay.
-
Change the program i am using and move to unity. However, be careful as unity has a larger learning curve.
- However, I would spend a few days max learning and research about the software, and if it takes too long go back to adobe animate and continue building the game.
On the Unity website, I found the section for detailed tutorials with easy to follow videos. They also include game files that you could follow to build the simple game.
I started by Placing a 2d GameObject Circle and adding a player movement script. To add physics to unity i rigidbody compenet needs to be added
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour {
public float speed;
private Rigidbody2D rb;
private Vector2 moveVelocity;
void Start(){
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
Vector2 moveInput = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
moveVelocity = moveInput.normalized * speed;
}
void FixedUpdate()
{
rb.MovePosition(rb.position + moveVelocity * Time.fixedDeltaTime);
}
}
When the circle was moving i added a script to the camera to follow the plater, instead of making the Circle GameObject a child of the Camera to add smoother movement and using a script is better.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFollow : MonoBehaviour
{
public Transform followObject;
private Vector3 moveTemp;
public float offsetY = 0;
public float offsetX = 0;
// Start is called before the first frame update
void Start()
{
moveTemp = followObject.transform.position;
}
// Update is called once per frame
void Update()
{
moveTemp = followObject.transform.position;
moveTemp.y += offsetY;
moveTemp.x += offsetX;
moveTemp.z = transform.position.z;
transform.position = moveTemp;
}
}