Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Shooter : MonoBehaviour {
- public Rigidbody bullet;
- public float power = 1500f;
- public float moveSpeed = 2f;
- void Start () {
- }
- // Update is called once per frame
- void Update ()
- {
- float h = Input.GetAxis("Horizontal")*Time.deltaTime*moveSpeed;
- float v = Input.GetAxis("Vertical")*Time.deltaTime*moveSpeed;
- transform.Translate(h,v,0);
- if (Input.GetButtonUp("Fire1"))
- {
- Rigidbody instance = Instantiate(bullet, transform.position, transform.rotation) as Rigidbody;
- Vector3 fwd = transform.TransformDirection(Vector3.forward);
- instance.AddForce(fwd*power);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement