Currently working on a football project, but I’m having trouble. I want the function be ran multiple times simultaneously, when it makes the football player NPC follow a specific route. Routes are formatted like this in an array:
[
[duration, Yvelocity], <— wait for duration, than set velocity
[duration, Yvelocity]
]
The way the function is supposed to work is the NPC follows a specific route, but sometimes the velocity will act erratically. And only one route can run at a time it seems.
Could you share the link? I cant think / properly solve problems without way more info than you’d think is necessary. Well I guess my brain works like that.
A more detailed explanation of why the global variables posed a problem:
Open for more detail
The values for the global variables are set before the pause runs. After the pause finishes, those global variables may have been replaced with different values with a separate call to run route.
You could try moving the block that sets the value of routeVelocity after the pause block, and that might work just fine. Still, you risk this same kind of clash when the function is called multiple times.
The function holds on to a reference to the array until the call has finished. (It’s a parameter, so it’s a local variable specific to the function call.) So, when calling this function multiple times in parallel, accessing the values of the array directly (in other words, accessing the parameter) is the safest way to go.
This has been a side-project of mine for a while, so I’ve been working on it incrementally. But it’s coming together nicely, so basically, more posts are coming soon.