You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
955 B

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class paintShoot : MonoBehaviour
{
private Rigidbody2D paintBlob;
public GameObject player;
// Start is called before the first frame update
void Start()
{
player = GetComponent<GameObject>();
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.E))
{
Debug.Log("shooting");
Instantiate(paintBlob, player.transform);
if (player.GetComponent<movement>().faceRight)
{
paintBlob.velocity = transform.TransformDirection(Vector2.right);
}
else
{
paintBlob.velocity = transform.TransformDirection(Vector2.left);
}
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
//This is where you would damage the enemy
}
}