#bunp halp
1 messages · Page 1 of 1 (latest)
whats a vector 😂
Welcome to Nature of Code Chapter 1: Vectors! What is a vector? How do they work in p5.js? These questions will all be answered in this first section of this series on p5.Vector.
💻Code : https://thecodingtrain.com/learning/nature-of-code/1.1-what-is-a-vector.html
📗NOC Chapter : https://natureofcode.com/book/introduction/
🎥Next video : https://y...
I posted a diagram of my problem there now
This might be an X/Y problem
what im TRYING to achieve is
when you walk against a wall, you slide along the wall at the EXACT same speed as you would if your input direction was right into the wall
except to intercept corners and move around them
the blue values are the expected return values, the 'true' blue values are
A = (1, 0)
B = ( 0.7, 0.7)
but I want to return the blue values from the picture, when only knowing those numbers, and what numbers red has
but in reality, those values are all entirely dependant on the input direction
I want to input (0,7, 0,7) as my true input vector, have the code intercept that input and return a vector of the same magnitude as the input, which in this case is (1, 0)
but THEN I want to shorten the magnitude of that vector to a value that would return how fast you would move if you were actually inputting (0.7, 0.7)
so my suggestion would be the following
calculate the directional vector (with the wrong magnitude)
then normalize that directional vector
and multiply the normalized directional vector by the magnitude of your input vector
as I change the input vector (the magnitude of the vector is unchanged) the character moves faster. You can see the input vector is directly between the two white lines
In this gif, I want the input vector to always be exactly RIGHT, which is (1, 0) but I want it to move at exactly the same speed you in this gif
right now the code is unimportant because it doesnt do that above behaviour
@surreal coral why arent you just listening to what im telling you to do. what do you not understand.
I can get the direction I want already, im trying to fake the real speed behaviour you would get if I was using the real input vector instead of the fake one
so your cahr only moves on on axis?
no
why does it not move upward in the gif then
sorry this other guy has been blasting me, let me read what you wrote now
because there is a collider
sounds like thats your issue honestly
ffs
you arent helping, at all, and you arent understanding, at all, im sorry its pointless to continue, im going to only reply to Keep now
@jovial sorrel get out of this thread if youre gonna be unhelpful
it moves faster because it points more sideways
please leave
¯_(ツ)_/¯
bunp. you just said you can already get the right directional vector based on your input vector
now you just want to make sure its slower when you hold both axes down right
Right yeah, let me re-read what you wrote
https://cdn.discordapp.com/attachments/497874004401586176/907674848820609035/speed.gif
in this gif the two white lines are represensitive of the adjusted movement vector
so when your input is 45 degres up and right, you can see the corrected vector is fully right
so I will look at your code now
https://cdn.discordapp.com/attachments/907655294216187954/907668578688454717/unknown.png
newY = Mathf.Abs(collisionReporting.dirRight.y) * trueMoveDirection.y;
newX = Mathf.Abs(collisionReporting.dirRight.x) * trueMoveDirection.x;
this is my old code for ref, based on this bellow image
you want to take the vector you're using to draw the 'right' line there
then just normalize that and multiply it by the magnitude of your original input vector
dirLeft is used if its the left line that is "clear" and dirRight is used if its the right, they are raycasts
if I understand correctly
normalizing changes the vector to be a magnitude of 1? and then multoplying by the original magnitude, which was also 1? Wouldnt that do nothing?
you said your original input vector had a lower magnitude
Oh, no that is not the case, I must have explained it wrong
the input is an analog stick Vector2 range between 0 and 1, or a keyboard/dpad input that is exactly 0 or 1
which is then normalized magnitude of no grreater than 1
you want to have an object that moves into the right direction if you press WD, but have it move slower than if you were holding just D right
360 degree sadly
keyboard/dpad is only 8 direction
but analog stick is full all angles
...but then why do you need to move right when its exactly at 45 degrees
I dont? thats another misunderstanding on your part
.
.
oh right okay sorry, this problem is extremely complex, I misunderstood what you just said
So from what I get you want to not slow down despite running into a wall partially
If you already have the normalized blue vector in your image, just multiply it by the magnitude of your original vecto
If not, you likely want to poke a raycast to the wall to get it's normal and from that coupled with the offset calculate the blue vector and then multiply it by your original magnitude
...but then why do you need to move right when its exactly at 45 degrees
this is why:
you wont slide over the corner if you move the actual movement vector you are inputting
what the fuck kinda movement system is this, and doesnt that make your movement system bidirectional?
you just said its 360 degrees
you arent understanding, I dont appreciate the attitude
I keep trying to explain it in simpler simpler terms
i dont think you understand what you're asking tbh
you say your movement is in any direction, but then if you move in a certain direction its suddenly not supposed to go in that direction?
you keep changing your requirements
the requirements never change
maybe it will help if I try to explain literally everything, step by step, from the beginning for you
... where did my post just go
did someone just delete my post
I guess Ill have to retype that entire thing :|
okay discord is fucked
I just typed the entire thing twice
and it deleted it both times
that worked
I dont know why that posted
maybe, ill type it a THIRD time in notepad
if its too long it wont post it
FULL EXPLAINATION
player inputs move vector, test case is 45 degrees, WD, up right, (0.7, 0.7)
true use case is any magnitude of any angle.
Against a solid colider, player slides along the surface of the wall at velocty of X.
When the player hits a lip on the collider, the held direction will never move around the lip ever.
The true input direction is intercepted when the player is colliding with walls and replaced with a new direction vector that is angled 45 degrees off from the true angle they are inputting.
The problem is that you move much much faster in the intercepted angle than in the true angle sliding along the wall.
Sliding along the wall moves at the speed depicted in the gif above
it looks like if your post has any row of negatives in it, it gets automatically deleted
you cant say "--" but with more of them, instantly deleted
@white crescent does that make sense now?
expected result
actual result, velocity is erronius
due to my math being wrong, which is what im trying to solve
Im cooking dinner now but i might look at this in a bit
Cool, Im going to take a walk to clear my head. Here are my code snippets
private void SlideAround()
{
dirLeft = (Vector2)(Quaternion.Euler(0, 0, playerControlManager.moveDegree - 45f) * Vector2.left);
dirRight = (Vector2)(Quaternion.Euler(0, 0, playerControlManager.moveDegree + 45f) * Vector2.left);
dirLeft.Normalize();
dirRight.Normalize();
rightIsClear = RayTest(dirLeft, playerRadius);
leftIsClear = RayTest(dirRight, playerRadius);
}```
code that gets angles 45 degrees before/after input angle
if (collisionReporting.leftIsClear && !collisionReporting.rightIsClear)
{
Vector2 movement = collisionReporting.dirRight.normalized * Vector2.Dot(trueMoveDirection, collisionReporting.dirRight.normalized);
return movement;
}
else if (collisionReporting.rightIsClear && !collisionReporting.leftIsClear)
{
Vector2 movement = collisionReporting.dirLeft.normalized * Vector2.Dot(trueMoveDirection, collisionReporting.dirLeft.normalized);
return movement;
}
code that uses those angles currently
the line Vector2 movement = collisionReporting.dirRight.normalized * Vector2.Dot(trueMoveDirection, collisionReporting.dirRight.normalized);
is just a current broken attempt, you can ignore it
previous broken attempts
newY = Mathf.Abs(collisionReporting.dirRight.y) * trueMoveDirection.y;
newX = Mathf.Abs(collisionReporting.dirRight.x) * trueMoveDirection.x;
newY = collisionReporting.dirRight.y;
newX = collisionReporting.dirRight.x;
Vector 2 movement being made from newX and newY