Refactoring Prefabs
This commit is contained in:
@@ -10,16 +10,20 @@ public class BulletMoving : MonoBehaviour
|
||||
[SerializeField]
|
||||
private Rigidbody rb;
|
||||
|
||||
private Vector3 direction = new Vector3(0f,0f,0f);
|
||||
|
||||
|
||||
private
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
rb = parent.GetComponent<Rigidbody>();
|
||||
direction = transform.position - parent.transform.position;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
rb.velocity = dataBullet.direction * dataBullet.speed;
|
||||
rb.velocity = direction * dataBullet.speed;
|
||||
}
|
||||
}
|
||||
|
@@ -10,8 +10,6 @@ public class DataBullet : ScriptableObject
|
||||
|
||||
public float speed = 5f;
|
||||
|
||||
public Vector3 direction = new Vector3();
|
||||
|
||||
public int ammo;
|
||||
|
||||
public void setDamage(float damage){
|
||||
|
@@ -10,9 +10,8 @@ MonoBehaviour:
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 9e1d27c11e7949e4fa59cefee3928ca4, type: 3}
|
||||
m_Name: BulletData1
|
||||
m_Name: DataBullet
|
||||
m_EditorClassIdentifier:
|
||||
damage: 10
|
||||
speed: 2
|
||||
direction: {x: 1, y: 0, z: 0}
|
||||
speed: 10
|
||||
ammo: 4
|
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 215ad7d91b06f2741b40dc3806033238
|
||||
guid: cafd241bae342f446ae8141cc5d72daf
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
30
Plunderblock/Assets/Scripts/ScriptsKevin/WeaponScript.cs
Normal file
30
Plunderblock/Assets/Scripts/ScriptsKevin/WeaponScript.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class WeaponScript : MonoBehaviour
|
||||
{
|
||||
|
||||
public GameObject parent;
|
||||
public GameObject bullet;
|
||||
|
||||
|
||||
public void shoot(){
|
||||
if(Input.GetKeyDown(KeyCode.Mouse0)){
|
||||
Instantiate(bullet,transform.position,parent.transform.rotation);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
shoot();
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0262bbe3025ed14984b9ca540206237
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user