How to update 100 cars position from pre-set coordinates every 0.1 second?
Hi
I am new to Unity. Please help to point me in the direction
I have 100 cars in a scene, and have their coordinates (x,y,z) in the text file every 0.1 second from a simulation software.
How can I load them and play/move/rotate these cars and record a video?
The tutorial below does not do exactly what I want https://unity3d.com/learn/tutorials/projects/2d-roguelike-tutorial/moving-object-script
Answer by NorthStar79 · Jan 16, 2018 at 11:47 AM
Hello, you are not very familiar with unity i guess, so i will try to be very simple. Please note that this is not the most optimal way to implement this kind of behaviour but I guess most simple one.
first adjust your fixedTime step to 0.1 seconds here how to do it :
then create this script and attach it every car you have.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class car : MonoBehaviour {
float xValue,yValue,zValue;
void FixedUpdate () {
gameObject.transform.Translate(xValue,yValue,zValue);
}
}
that should mode them, note that you need to read xValu,yValue and zValu from your text and assign them. i can not help you about that because i have no idea how you keed that data.
if you need rotations too, just write witch format you record your rotations i will try to implement that too.
Your answer
Follow this Question
Related Questions
i have a problem 2 Answers
how do i fix the compiler errors on unity 5? i have tried everything there is to try. 0 Answers
Move player based on UI controls 0 Answers
Object Manipulation and a foreign object 0 Answers
Finger Swipe on Object 2 Answers