Method no longer executes properly after exporting project
I wrote a teleportation method that triggers the start of the timeline when the character walks to the specified place, and calls this method through a single at the appropriate place in the timeline, everything works fine when I run it in unity, but when I export the game and After triggering this method the character moves to a strange position and cannot move (probably all the characters' scripts can no longer be executed , and i changed the scene halfway)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace RW.MonumentValley
{
public class BlinkController : MonoBehaviour
{
public enum PlayerAxis
{
X,
Y,
Z
}
[SerializeField] private Node goalNode;
[SerializeField] private Node nextNode;
[SerializeField] private PlayerAxis playerAxis = PlayerAxis.X;
private Transform playerTransform;
private Pathfinder pathfinder;
private Vector3 goalLocation = new Vector3();
private PlayerController playerController;
private Vector3 roleOrientation;
// Start is called before the first frame update
void Awake()
{
playerController = FindObjectOfType<PlayerController>();
pathfinder = FindObjectOfType<Pathfinder>();
}
void Start()
{
goalLocation = goalNode.transform.position;
playerTransform = GameObject.FindGameObjectWithTag("Player").GetComponent<Transform>();
switch (playerAxis)
{
case (PlayerAxis.X):
roleOrientation = Vector3.right;
break;
case (PlayerAxis.Y):
roleOrientation = Vector3.up;
break;
case (PlayerAxis.Z):
roleOrientation = Vector3.forward;
break;
}
}
public void Transmit()
{
Vector3 directionToNextNode = nextNode.transform.position - goalNode.transform.position;
pathfinder.ChangeStartNode(goalNode);
playerTransform.position = goalLocation;
playerTransform.rotation = Quaternion.LookRotation(directionToNextNode, roleOrientation);
playerController.StopMoving();
playerController.SnapToNearestNode();
playerController.FaceNextPosition(goalNode.transform.position, nextNode.transform.position);
playerController.transform.parent = goalNode.transform;
}
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613054114im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to add Animation Events in the Timeline editor? 5 Answers
How to make my timeline animation 30 fps? 1 Answer
Unity 2019 Step Key Animation Issue from Maya 0 Answers
Controlling game elements with timeline 1 Answer
How to record gameobject positions during playmode in the timeline editor ? 0 Answers