#Parachute Motion
1 messages · Page 1 of 1 (latest)
try this: normalizedInput = VelocityDirection(new Vector3(transform.position.x, 0, transform.position.z));
tried that but still nothing, I keep moving to the left:
normalizedInput = VelocityDirection(new Vector3(transform.position.x, 0, transform.position.z));
inputDirection = transform.right * normalizedInput.x + transform.forward * normalizedInput.z;
if (inputDirection.x != 0 || inputDirection.z != 0) parachuteDirection = inputDirection;
did I do something wrong?
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
Hold on..
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:
let me upload my script because I don't think we are trying to do the same thing here:
https://gdl.space/awuvuzeboj.cpp
Okay, checking out...
What's your stats class like?
hey, sorry I didn't notice the message, @ me and I'll respond faster
my stats class contains many variables but it has absolutely nothing to do with the part of the code that is not working
but here, you can take a look if you want:
https://gdl.space/wisezubeke.cs
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).
what??
You don't understand?
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.
honestly no idea what you are talking about
Can you show a sample of the left/right motion you mean?
sure let me just get the stream going real quick
Ouch!
Okays
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
Yeah
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
{
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;
}```
I don't see how any of that is getting my velocity, am I wrong?
not sure you understand what I want
Comment out: normalizedInput = Vector3.Normalize(new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")));
direction = transform.right * normalizedInput.x + transform.forward * normalizedInput.z;
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...
Forget about the first code I sent
kind of need that part too because I'd like it to depend on input too
Yea Input would work as well
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