#What if
1 messages · Page 1 of 1 (latest)
ok so
its doing nothing
and i want to switch tag from gamer to ded
once it touches
this object'
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.SocialPlatforms.Impl;
public class atak : MonoBehaviour
{
public GameObject objectToDuplicate;
private bool hasBeenDuplicated = false;
public float someCooldown;
private float number = Mathf.Infinity;
[SerializeField] private float distance = -3;
public GameObject gameoverscreen;
public GameObject dude;
void Update()
{
number += Time.deltaTime;
if (number > someCooldown)
{
GameObject susiObject = Instantiate(objectToDuplicate, transform.position, transform.rotation);
Rigidbody2D susiRigidbody = susiObject.GetComponent<Rigidbody2D>();
susiRigidbody.constraints = RigidbodyConstraints2D.FreezePositionX | RigidbodyConstraints2D.FreezeRotation;
susiRigidbody.velocity = new Vector2(0.0f, distance);
number = 0;
}
if (dude.gameObject.CompareTag("ded"))
{
gameoverscreen.SetActive(true);
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (dude.CompareTag("gamer"))
{
dude.tag = "ded";
}
}
} //dude```
full script
how about an bool isDed on the dude instead of swapping tags around
this is script thats inside duplicating object
I'd second something like that
okay
lemme try that
Also, I'd try throwing in some logs to 1) see where in the code it's actually getting to, and 2) to see what the code is actually changing
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.SocialPlatforms.Impl;
public class atak : MonoBehaviour
{
public GameObject objectToDuplicate;
private bool hasBeenDuplicated = false;
public float someCooldown;
private float number = Mathf.Infinity;
[SerializeField] private float distance = -3;
public GameObject gameoverscreen;
public GameObject dude;
public bool dang = false;
void Update()
{
number += Time.deltaTime;
if (number > someCooldown)
{
GameObject susiObject = Instantiate(objectToDuplicate, transform.position, transform.rotation);
Rigidbody2D susiRigidbody = susiObject.GetComponent<Rigidbody2D>();
susiRigidbody.constraints = RigidbodyConstraints2D.FreezePositionX | RigidbodyConstraints2D.FreezeRotation;
susiRigidbody.velocity = new Vector2(0.0f, distance);
number = 0;
}
if (dang == true)
{
gameoverscreen.SetActive(true);
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (dang == false)
{
dang = true;
}
}
} //dude```
i did that
like
when i change dang to true in test mode
game over screen appears
but when i touch the object that has trigger inside it
it doesnt execute if command
prefab has a trigger
code isnt wrong so what could be wrong here
You mean when you manually change it in the editor during the play test mode?
I'm not seeing in the inspector where you're changing it
Oh I thought that's what you were trying to show in the screenshot
But I see now it was part of your second message
Alrighty. Let me know how it goes
with this collider wasnt like inside the eye
so i removed prefab and made it dupe a gameobject
it did fix it
now colliders are inside those objects itself
but
still when colliding its not working
I'm guessing the properties you're modifying are not the ones for the instance of the prefab
What's up?