fireball move to target
This commit is contained in:
parent
81742e400e
commit
772023d79a
6 changed files with 77 additions and 3 deletions
|
@ -10,6 +10,8 @@ GameObject:
|
|||
m_Component:
|
||||
- component: {fileID: 6846999857528980846}
|
||||
- component: {fileID: 6846999857528980841}
|
||||
- component: {fileID: -6779566855310870620}
|
||||
- component: {fileID: -3086558469575312007}
|
||||
m_Layer: 0
|
||||
m_Name: Fireball
|
||||
m_TagString: Untagged
|
||||
|
@ -25,7 +27,7 @@ Transform:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6846999857528980847}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 10.24, y: 0.43, z: 0.9882064}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
|
@ -82,3 +84,41 @@ SpriteRenderer:
|
|||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!114 &-6779566855310870620
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6846999857528980847}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 29d9315c47af84e10b87b79f5cbe2ecb, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!61 &-3086558469575312007
|
||||
BoxCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6846999857528980847}
|
||||
m_Enabled: 1
|
||||
m_Density: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_UsedByEffector: 0
|
||||
m_UsedByComposite: 0
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_SpriteTilingProperty:
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
oldSize: {x: 1, y: 1}
|
||||
newSize: {x: 1, y: 1}
|
||||
adaptiveTilingThreshold: 0.5
|
||||
drawMode: 0
|
||||
adaptiveTiling: 0
|
||||
m_AutoTiling: 0
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 1}
|
||||
m_EdgeRadius: 0
|
21
Assets/Scenes/Scripts/Fireball.cs
Normal file
21
Assets/Scenes/Scripts/Fireball.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Fireball : MonoBehaviour
|
||||
{
|
||||
public float speed = 1.0f;
|
||||
public Vector2 destination;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Debug.Log("Fireball destination:");
|
||||
Debug.Log(destination);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
float step = speed * Time.deltaTime;
|
||||
transform.position = Vector3.MoveTowards(transform.position, destination, step);
|
||||
}
|
||||
}
|
11
Assets/Scenes/Scripts/Fireball.cs.meta
generated
Normal file
11
Assets/Scenes/Scripts/Fireball.cs.meta
generated
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 29d9315c47af84e10b87b79f5cbe2ecb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -14,9 +14,11 @@ public class FireballSpawner : MonoBehaviour
|
|||
{
|
||||
Vector3 mouseClickFromCamera = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
mouseClickFromCamera.z = 0;
|
||||
|
||||
GameObject spawnedFireball = Instantiate(fireball, dragonHead.transform.position, Quaternion.identity);
|
||||
Debug.Log(mouseClickFromCamera);
|
||||
Debug.Log(dragonHead.transform.position);
|
||||
spawnedFireball.GetComponent<Fireball>().destination = mouseClickFromCamera;
|
||||
/* Debug.Log(mouseClickFromCamera); */
|
||||
/* Debug.Log(dragonHead.transform.position); */
|
||||
/* gameObject.transform.position = pz; */
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue