- using UnityEngine;
- using System.Collections;
- public class Bullet : MonoBehaviour
- {
- [Header("BulletConfig")]
- public int range;
- public int damage;
- public float mass;
- public float speed;
- [Header("Imports")]
- public PlayerController Player;
- public ParticleSystem impact;
- //Privates
- private Rigidbody rb;
- private Vector3 origin;
- void Start()
- {
- rb = GetComponents
(); - origin = transform.position;
- }
- void Update()
- {
- //Massa
- rb.mass = mass;
- //Frente
- Vector3 horizontal = transform.right * 0;
- Vector3 vertical = transform.forward * 1;
- Vector3 velocity = (horizontal + vertical).normalized * speed;
- rb.MovePosition(rb.position + velocity * Time.fixedDeltaTime);
- //Range
- if (Vector3.Distance(origin, transform.position) > range)
- {
- Destroy(GameObject);
- }
- private void OnCollisionEnter(Collision collision)
- {
- Destroy(gameObject);
- if (collision.gameObject.tag == "Terrain")
- {
- GameObject eff = Instantiate(impact, collision.transform.position, Quaternion.Identity).gameObject;
- eff.transform.position += new Vector3(0, 0.1f, 0);
- eff.transform.eulerAngles = new Vector3(-90, 0, 0);
- }
- }
- }
- }
The modifier ‘private’ is not valid for this item
I'm having a problem and i don't know how to resolve it. The error is on the line 42 of the code:
Jignesh KumarPosted May 28, 2020, 1:08 AM
Salman BegPosted May 27, 2020, 8:48 PM