#bunp halp

1 messages · Page 1 of 1 (latest)

white crescent
#

@surreal coral if youre still having trouble please write in this thread ill try to help you

deft lake
#

whats a vector 😂

white crescent
# deft lake 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...

▶ Play video
deft lake
#

thx

#

How did you learn how to code?

#

I use an app called sololearn

white crescent
#

just do it a lot, and code along videos like the above

#

also uni courses

deft lake
#

ok thx

#

what are you working on?

surreal coral
#

sorry I had an apointment there, back now

surreal coral
#

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)

white crescent
#

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

surreal coral
#

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

jovial sorrel
#

I mean still

#

whats your code 🤔

surreal coral
#

right now the code is unimportant because it doesnt do that above behaviour

white crescent
#

@surreal coral why arent you just listening to what im telling you to do. what do you not understand.

surreal coral
#

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

jovial sorrel
#

so your cahr only moves on on axis?

surreal coral
jovial sorrel
#

why does it not move upward in the gif then

surreal coral
surreal coral
jovial sorrel
#

sounds like thats your issue honestly

surreal coral
#

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

white crescent
#

@jovial sorrel get out of this thread if youre gonna be unhelpful

jovial sorrel
#

it moves faster because it points more sideways

surreal coral
#

please leave

jovial sorrel
#

¯_(ツ)_/¯

white crescent
#

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

surreal coral
#

Right yeah, let me re-read what you wrote

#

so I will look at your code now

white crescent
#

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

surreal coral
#

dirLeft is used if its the left line that is "clear" and dirRight is used if its the right, they are raycasts

surreal coral
#

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?

white crescent
#

you said your original input vector had a lower magnitude

surreal coral
#

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

white crescent
#

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

surreal coral
#

so if you are holding W and D, you get Vec2(0.7, 0.7)

#

Yes exactly

white crescent
#

any inbetween cases?

#

or is it 8 directional

surreal coral
#

360 degree sadly

#

keyboard/dpad is only 8 direction

#

but analog stick is full all angles

white crescent
#

...but then why do you need to move right when its exactly at 45 degrees

surreal coral
#

I dont? thats another misunderstanding on your part

white crescent
#

bruh

#

thats what youve been saying this entire time

white crescent
surreal coral
#

oh right okay sorry, this problem is extremely complex, I misunderstood what you just said

jovial sorrel
#

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

surreal coral
#

you wont slide over the corner if you move the actual movement vector you are inputting

white crescent
#

you just said its 360 degrees

surreal coral
#

you arent understanding, I dont appreciate the attitude

#

I keep trying to explain it in simpler simpler terms

white crescent
#

i dont think you understand what you're asking tbh

surreal coral
#

I know exactly what im asking

#

you arent understanding it, thanks

white crescent
#

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

surreal coral
#

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

white crescent
#

u might be hitting a spam filter

#

try to split ur message in two

surreal coral
#

maybe, ill type it a THIRD time in notepad

white crescent
#

if its too long it wont post it

surreal coral
#

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

white crescent
#

Im cooking dinner now but i might look at this in a bit

surreal coral
#
    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