#Parachute Motion

1 messages · Page 1 of 1 (latest)

signal estuary
#

try this: normalizedInput = VelocityDirection(new Vector3(transform.position.x, 0, transform.position.z));

crimson scroll
#

also a question, is it possible to get rb's velocity like my function here did but that it actually works?

        if (v3.x > 0 && v3.z > 0) return new Vector3(0.75f, 0, 0.75f);
        else if (v3.x < 0 && v3.z > 0) return new Vector3(-0.75f, 0, 0.75f);
        else if (v3.x > 0 && v3.z < 0) return new Vector3(0.75f, 0, -0.75f);
        else if (v3.x < 0 && v3.z < 0) return new Vector3(-0.75f, 0, -0.75f);
        else if (v3.x > 0) return new Vector3(1, 0, 0);
        else if (v3.x < 0) return new Vector3(-1, 0, 0);
        else if (v3.z > 0) return new Vector3(0, 0, 1);
        else if (v3.z < 0) return new Vector3(0, 0, -1);
        else return Vector3.zero;

if yes, that's all I need

signal estuary
#

Hold on..

signal estuary
#

I checked out your code, wrote the same thing, except that I'm using 'transform.position' and moving with rb.velocity.. However it works as intended(direction changes depending on the axis I moved the object), here's a log sample:

crimson scroll
signal estuary
#

What's your stats class like?

crimson scroll
crimson scroll
signal estuary
#

Your VelocityDirection() would only switch the parachute's direction if the parachute's position is within these values(0, 1, 0.75f). For instance if the parachute is moving forward and you want an instant change in direction, say backwards; you have to manually move the parachute(in scene view) till it gets to a value less than zero(0).

crimson scroll
#

what??

signal estuary
#

Btw, I'm not sure it's possible to switch the direction if you're not controlling it with input, 'cause you keep applying constant motion if a condition is met.

crimson scroll
signal estuary
#

Can you show a sample of the left/right motion you mean?

crimson scroll
#

sure let me just get the stream going real quick

signal estuary
signal estuary
crimson scroll
# signal estuary Ouch!

not your fault my scripts are messy and you probably didn't get something right or I just can't understand what you are trying to say

crimson scroll
#

there you go

#

first I showed how it works properly with input and then what the problem is with rb.velocity

#

it's kind of hard to tell what's actually happening since you are not pressing keys but you can see that it's not moving in the right direction

signal estuary
#
    {
        normalizedInput = VelocityDirection(new Vector3(transform.position.x, 0, transform.position.z));

       // normalizedInput = Vector3.Normalize(new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")));

      // direction = transform.right * normalizedInput.x + transform.forward * normalizedInput.z;

        if (normalizedInput.x != 0 || normalizedInput.z != 0)
            direction = normalizedInput;

        var velocity = moveSpeed * Time.deltaTime * direction;

        rb.velocity = velocity;
    }```
crimson scroll
#

I don't see how any of that is getting my velocity, am I wrong?

#

not sure you understand what I want

signal estuary
crimson scroll
#

I would like to get rb's current velocity and transform it to one of these:
1, 0, 0
0, 0, 1
-1, 0, 0
0, 0, -1
0.75, 0, 0.75...

signal estuary
#

Forget about the first code I sent

crimson scroll
signal estuary
crimson scroll
#

it works by checking for rb's velocity, changing it to that and if there is no input just skipping, however if there is an input it changes to that