Hello, I can’t seem to fix this problem. If you know how I should fix it, I would be very happy. Here’s my 2 scripts:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShootAwayBat : MonoBehaviour
{
public Rigidbody2D rb;
public float speed;
public bool sak;
public bool sak2;
public GameObject enemy;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
if (sak == true) {
transform.position += transform.right * speed * Time.deltaTime;
}
if (Input.GetKeyDown(KeyCode.Q)) {
Debug.Log("ENsak");
sak = true;
}
}
void OnTriggerEnter2D (Collider2D col) {
if (col.gameObject.tag == "Head") {
col.gameObject.GetComponent<teleport> ().Teleport1();
}
}
}
and the other:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class teleport : MonoBehaviour
{
public Transform player;
public Transform ensak;
// Start is called before the first frame update
void Start()
{
ensak = GameObject.FindGameObjectWithTag("ensak").transform;
player = GameObject.FindGameObjectWithTag("Player").transform;
}
public void Teleport1() {
ensak.position = player.position;
player.position = this.transform.position;
ensak.position = this.transform.position;
}
}
[quote=“Zalosath, post:2, topic: 804540, username:Zalosath”]
What line is the error on?
[/quote] on the col.gameObject.GetComponent<teleport> ().Teleport1(); thanks!
Expect to see this error a LOT. It’s easily the most common thing to do when working. Learn how to fix it rapidly. It’s easy. See the above link for more tips.