Hello good people!
I know I can’t use the proper trems in my title for what I’m trying to figure out. It’s why it’s been a nightmare trying to find help through google. So I’m asking here if I can get an explanation.
I’ve got two scripts. A player movement script and an ability script. (Trying to make a dash ability)
I’m following a tutorial, kind of… It’s using rigidbodies while I’m not, so I have to try to translate it through different code.
In the player script I’ve got this:
public void Movement(Vector3 velocity)
{
cc.Move(velocity * Time.deltaTime);
}
This approach was kind of new to me. Before, I would have just done a public void Movement, with nothing in the brackets, and then referenced inside the function. But since I can… I think it’s called delegate in programming lingo… It seems to be a bit smarter… But I don’t fully understand it…
Now this is the second script:
public Update()
{
if(setVelocity)
{
player.Movement(vector.forward * velocityToSet);
}
}
Here is the thing… Yes, it’s not working. And I know it’s because I’ve done something wrong, and haven’t figured it out yet. But to be honest, I got stuck even before that.
The velocity vector I’m giving the movement function is just my input*player speed.
Here is where I’m stuck.
In the second script, I want the player to dash forward (towards where he’s aiming) by a set amount. (velocityToSet is a float supposed to state that amount)
But I don’t know how to delegate into the movement function while still retaining the velocity vector that’s already being put into it?. (I’m imagining some kind of player.Movement(player.velocity * velocity, but htat didn’t work either. The player literally just disappears and the game turns unresponsive…)
Also, the tutorial I’m following uses rigidbody and 2d, while I’m trying to implement stuff without a rigidbody in 3d… And so many tutorials out there insists on using rb.velocity for movement… And I just can’t wrap my head around translating that into an ordinary charactercontroller. XD