I’ve noticed the ship travels very fast each time I start. I didn’t really notice this effect till we tuned the “Look ahead for target” variable down from 5 to 1. It seems my ship clears 2 or 3 way-points very quickly and then only travels slower from that point forward. Has anyone else noticed this? Any suggestions on how to stop this from happening?
I’m also having the same issue and am unable to figure out the solution as to why.
I think in a bit the course will get around to looking over this to make at least a few improvements?
I was really fooling myself, that my change to the code was making any difference at all… After some more poking around I’ve found that just about the only thing that seems to have real direct effect on the speed the camera/player move is the WaypointProgressTracker.cs lookAheadForTargetOffset.
With the plan of perhaps having a boss section I made it private, instead of serialized, and then made a public method to set it from another script. If you set it to zero, you just don’t move (enter boss-fight) then you can set it to something around 1 perhaps for typical flight; of course it then leaves the possibility to now add an afterburner boost or the like… jump it to 2 for half a second or something Lots of potential to mess with it.
Below this line is pre-edit…
For now, in my WaypointProgressTracker.cs I’ve changed what I now have as lines 91-96 to something more straightforward (in my inspector I’m using 20 for the inspector factor right now, in a circuit of seven waypoints, fwiw.)
if (Time.deltaTime > 0)
// speed = Mathf.Lerp(speed, (lastPosition - transform.position).magnitude/Time.deltaTime,
speed = inspectorFactor * Time.deltaTime;
It has smoothed-out my camera quite a bit, but it’s still imperfect… it’s particularly slow around corners and relatively fast in the long stretches between waypoints, and right at the end of the loop it does a big boost then a big slow… Definately needs some work!
Thanks for the link to the thread, In one of the currently available videos Ben spots this so a fix is likely on the way.
I’m getting a bit fed-up with Unity’s ropey component here, so once we’ve used Timeline for the enemies I’ll consider swapping-out the player movement to that too.
WaypointProgressTracker.cs, I have discovered (while adding a pause button from the SumPause asset via the asset store), also has no regard for the Time.timeScale game setting. It’s a fairly easy fix, because it’s variable lookAheadForTargetOffset is, for all practical purposes, the speed at which the object attached to it will be animated.
I forgot to check-in the file before I made my changes (derp) but if I recall I’ve only made two and a half changes to the file (not counting any changes Ben has pointed-out to us in the course). Those changes are: I have added 2 member variables and an IF statement to the Update() routine. I also added a couple public methods: GetForwardSpeed() and SetForwardSpeedSpeed().
Basically, I multiply the variable in question (lookAheadForTargetOffset) by Time.timeScale so that when timeScale = 0, so does lookAheadForTargetOffset. If you want the feature, but don’t want to solve the challenge yourself (or if you get stuck) you can always peek at my source code on GitHub: WaypointProgressTracker.cs
If you attach the camera directly to the waypoint tracker as a target this is what will happen (moving very inconsistently). This is because the tracker is not supposed to handle motion as strange as that sounds at first. I realized that the hard way as well, but basically the target in the tracker script is indicating in what direction the AI is supposed to make you move. You (via a separate AI script) can then decide on the velocity of the motion.
Here’s my code for the second AI script :
interpolatedTarget = waypointTarget.position;
Vector3 velocity = interpolatedTarget - transform.position;
velocity = velocity * 20.0f / velocity.magnitude;
transform.Translate(velocity * deltaTime);
It’s important that waypointTarget is a Transform that is separate from the camera (I just use an empty game object that serves no other purpose). Here in my “AI” script :
[SerializeField] Transform waypointTarget;
One fast solution for testing is that if you first pause the game before you hit play and then unpause it once it starts, Tte ship moves as expected. This makes me wonder if stopping movement for a second or two before starting would help solve this behavior.
Btw. Thanks so Much @JackDraak your script saved me a lot of frustration.
I had a similar issue where my ship would slow down and speed up near certain waypoints. I noticed that these waypoints were either very close to other waypoints or very far away. The solution I found was moving the waypoints so that they’re evenly spaced between each other. This greatly improved the smoothness of the camera. I can still see spots where it slows down a little but it’s very little and actually adds a bit of effect to the game (slowing down for turns/drops).
Hey guys, I was having the same problem and I think I may have figured out a solution to this issue, hope this helps! :
Thanks so much for this fix, I got half trough the course by just ignoring it but once I started reloading the scene on collision I had no choice but to find a fix, and this one was just as easy as it gets. THANKS!
PS: I had to change inspectorFactor to lookAheadForTargetOffset
PSS: I know we’ll evantually switch approaches, but looking ahead to do so now would have been a pain.
i was thinking the same thing lol this makes sense a little on why it would zoom like that. Worked 100%
Thanks, this helped me too, it does not start as smooth as yours, but before this, it was doing like the whole circuit on Fast Forward and then would come to normal speed. Now it starts for like 2 seconds with a bit of speed and then calms down .
Thank you for the solution!
I was just looking into this problem. Your solution worked perfectly for mine!
Though, I had to change to Y position as well.
this post made made my day! (a couple of them actually)
I get that the course is going to move on to using Timeline, but the constant speed hiccups were driving me insane during playtesting…
Thank you so much!
That helps alot:)
JoeyFatz, your suggestion (
) worked for me. Fantastic!
Dear JoeyFatz thank you very much.
I was also having this issue, and resetting the transform on the ship and the circuit is what fixed it for me.
I came here to share my solution but it looks like you all figured it out already!