Following the trail of Perlin Noise random movement?
Hey guys. Something I'm trying to figure out.
Basics: I have an object moving on a randomly generated Perlin Noise (let's call it TheWiggler) path, so it wiggles back and forth in the X position (z: 500). Objects spawn at this location and move at the player (who is at z: 0).
Pretty simple, makes a trail of objects coming at the player/screen that you avoid.
I'd love to figure out how to get the position of The Wiggler for where IT WAS at the same place my player is currently at.
Is this possible?
Here is my wiggler code:
private float _timer = 0f;
void Start()
{
}
void Update()
{
_timer += Time.deltaTime;
float height = GlobalControl.newPathCurveAmount * Mathf.PerlinNoise(_timer * GlobalControl.newPathCurveSpeed, 0.0F);
Vector3 pos = transform.position;
pos.x = height - (GlobalControl.newPathCurveAmount/2);
transform.position = pos;
}
So, any chance I can get the x position of where TheWiggler was when the objects finally reach my player? The harder part is that the TheWiggler slowly moves faster and faster(GlobalControl.newPathCurveSpeed and GlobalControl.newPathCurveAmount), and objects spawn faster and faster.
I'd love to have the coordinates for where the path "should be" at my player's position. Almost like the tail of the snake (which is what I want) from the head of the snake.
I really hope that makes sense! Any help?
Thanks!
Answer by subver · Nov 28, 2017 at 04:52 PM
If it matters, I want to use this so when my player dies, the camera (which is located just behind the player) follows the proper path. Obviously if I set it to follow "TheWiggler" it will be way off, following the path that is being created in z space 500 units away.
Any ideas would be really great!
I've thought about using the spawned object's positions as the path coordinates but I feel like there's gotta be a better way to do it (I feel like that would make things chug calculating that position every frame).. Essentially take that same PerlinNoise path except "back in time/where it was" if that is possible..
Thanks guys!
I think I'm starting to get close if I set private float _timer = -3.8f; on another script to offset the time and have the camera follow that offset path, it's not perfect but I might just need to keep adjusting the timer (so it matches up to where the player currently is).. not sure if it's really that simple or not but I'll fiddle with it some more and let you guys know.
Your answer
Follow this Question
Related Questions
Game Clock (Like in "The Escapist") 1 Answer
Wait time after coroutine's wait seconds is complete 0 Answers
how to display stopwatch ss\fff as string? 2 Answers
Mining in RTS 0 Answers