13-11-2020, Saat: 21:25
[attachment=119]sorunum hiyerarşi de olmayan bir prefaba bu scripti ekledim ama player kısmına birşey ekleyemiyorum player kısmı için hiyerarşiden fpscontroller ı sürükleyip player kısmına götürüyorum ama oraya ekleyemiyorum. ben player kısmının olmasını istemiyorum orası sabit olarak fpscontroller olmasını istiyorum bunu nasıl yaparım yardımcı olursanız çok sevinirim.
saldırı.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class saldırı : MonoBehaviour
{
public float torque = 500f;
public float thrust = 1000f;
private Rigidbody rb;
public Transform player;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
transform.LookAt(player);
Vector3 targetLocation = player.position - transform.position;
float distance = targetLocation.magnitude;
rb.AddRelativeForce(Vector3.forward * Mathf.Clamp((distance - 10) / 50, 0f, 1f) * thrust);
}
}
[attachment=119]
saldırı.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class saldırı : MonoBehaviour
{
public float torque = 500f;
public float thrust = 1000f;
private Rigidbody rb;
public Transform player;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
transform.LookAt(player);
Vector3 targetLocation = player.position - transform.position;
float distance = targetLocation.magnitude;
rb.AddRelativeForce(Vector3.forward * Mathf.Clamp((distance - 10) / 50, 0f, 1f) * thrust);
}
}
[attachment=119]