Professional Documents
Culture Documents
2D Games Unity
2D Games Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
void Start()
{
// Spawn player in the center of the map
Instantiate(player, new Vector3(0, 0, 0), Quaternion.identity);
void Update()
{
// Switch weapons with number keys or weapon wheel
if (Input.GetKeyDown(KeyCode.Alpha1))
{
currentWeaponIndex = 0;
}
else if (Input.GetKeyDown(KeyCode.Alpha2))
{
currentWeaponIndex = 1;
}
else if (Input.GetKeyDown(KeyCode.Alpha3))
{
currentWeaponIndex = 2;
}
else if (Input.GetKeyDown(KeyCode.Alpha4))
{
currentWeaponIndex = 3;
}
RPG 2D Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;