Moving triggers possible?
Hello everyone, I'm working on an infinite runner that currently spawns in obstacles and sends them moving towards you rather than trying to use prefabs and instantiations to create an infinite runner. I did this to save on the amount of coding required. However, I decided to add a shop system into the game and I can't get coins to work because of my decision. I have a simple collider that is a trigger and this is my script to move it:
using UnityEngine.UI;
using UnityEngine;
public class CoinMovement : MonoBehaviour
{
public Vector3 forwardForce;
public float speedUpMultiplier = 100f;
// Update is called once per frame
void FixedUpdate()
{
transform.Translate(forwardForce * Time.deltaTime);
}
void Update()
{
if (transform.position.z < -1)
{
Destroy(gameObject);
}
}
private void Start()
{
forwardForce.z+= Time.timeSinceLevelLoad * speedUpMultiplier; //this is used because I have the obstsacles speed up over time. on instantiation the new speed based on the time scince level load
//will be calculated
}
}
When I use this script is moves the coin as intended, however the OnTriggerEnter function is no longer called (in a separate script) after applying this script. Is there something I'm doing wrong? Or is it impossible to move triggers? Also, when I use this script to move the coins their rotation animation causes them to move circles around the central point which is where they should be. Thanks for your time.
Your answer
Follow this Question
Related Questions
Having issues with teleporting forward 0 Answers
Animations get screwed up when I add OnAnimatorMove function 0 Answers
My player does not turn around 0 Answers
Mecanim Generic No movement 0 Answers
How do i extend a animation ? 1 Answer