Tp3 + start TP4
This commit is contained in:
parent
57a40d426b
commit
3a7ce962e7
112 changed files with 63386 additions and 45 deletions
26
TP3/Assets/Scripts/RocketLauncher.cs
Normal file
26
TP3/Assets/Scripts/RocketLauncher.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class RocketLauncher : MonoBehaviour
|
||||
{
|
||||
[SerializeField] GameObject rocketPrefab;
|
||||
[SerializeField] Transform spawnTransform;
|
||||
[SerializeField] Rigidbody car;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.E))
|
||||
{
|
||||
GameObject rocket = GameObject.Instantiate(rocketPrefab);
|
||||
rocket.transform.position = spawnTransform.position;
|
||||
rocket.transform.forward = transform.forward;
|
||||
Rigidbody rb = rocket.GetComponent<Rigidbody>();
|
||||
rb.linearVelocity = car.linearVelocity;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue