#Late
1 messages · Page 1 of 1 (latest)
ok
so
it teleports you when you fall of the platform?
void tp()
{
if (player.transform.position.y - platform.transform.position.y < -50)
{
transform.position = new Vector3(transform.position.x, startposition.y, transform.position.z);
Debug.Log("fax");
}
}```
@pine bane
well at the point 20 subtracted from the platforms y
it doesnt teleport me back
in update
but... in lateupdate
it does teleport me to the y position that I state in the code
I could. but the if statement returns true in update as well
with my code that I am using now
ok try with mine
alright
nope
was it in update or late update?
update
what happens?
idk until i stopped it
i let it go on for like 10 seconds
ok
i fell pretty far
kk did it
and put it in the if instead of the 50
do i make the float equal 50?
what do i set the float to
make it a negative number
like wha
not that i know
void Update()
{
float distance = player.transform.position.y - platform.transform.position.y;
print(distance);
if (distance <= inspectorFloat)
{
transform.position = new Vector3(transform.position.x, startposition.y, transform.position.z);
Debug.Log("fax");
}
}
ok try this
and see the results
@pine bane
the float you set to -10
ok
i didnt know the name you gave it
ok but does it show the distance between the platform and player?
ok so
if you are under the platform does it print a negative value?
ok let me think something
void Update()
{
float distance = player.transform.position.y - platform.transform.position.y;
print(distance);
print(distance <= inspectorFloat);
if (distance <= inspectorFloat)
{
transform.position = new Vector3(transform.position.x, startposition.y, transform.position.z);
Debug.Log("fax");
}
}
@pine bane try the new print
whats that arrow
less than
oh whoops sorry i am dumb i was confused because I saw a arrow that returns a functio like thuis =>
< less than
<= less than or equal
i still dont teleport
oh yeah thats a lamba thingy
what does the console say?
the number just decreases
and the other print?
there were two?
um i dont know there were a tons of numbers popping up idk which is whic
does that print a bool
yes
what is the inspector float set to?
0
it printed true for a bit then started doing false again
ig it just has to be in lateupdate
void Update()
{
float distance = player.transform.position.y - platform.transform.position.y;
bool above = distance > inspectorFloat;
if (!above)
{
print("down");
transform.position = new Vector3(transform.position.x, startposition.y, transform.position.z);
Debug.Log("fax");
} else {
print("above");
}
}```
@pine bane
and the console?
if the player is above the platform what does the console say?
it always printed above
down was never printed
ok and if the player is under the platform?
i think it just prints above
bc down is never printed
its fine tysm for ur help. I am thankful u put a ton of time. i gtg for now. if u want to keep figuring it out with me i can tell u when i get back it shouldnt be long.
have a good day
boxfriend figured it out
all the math and work u were doing was completely right
we had it right the issue was the character controller
tysm for ur help tho
np
good luck
I have a question
someone asked this and i gave an answer i just want to make sure it was a good way
how would u go about doing this
how
so i have an input
how do i make the character point in the NE when the W and D keys are pressed
i just want to understand the logic, dont need code
whats NE?
north east
well first you need to define the north east
then check if the inputs are pressed
and
then if i'm not mistaken
you can set the transform.forward as your north east
my idea was if you can inputs from w and d then add to a vector2
that vector2 is your direction
so if you only do a
then add 1 to a certain place
is that a bad idea
adding to a vector2 and making that vector2 ur direction
well you probably can
declare a the vector2 and make the transform.forward that vector normalized
yea
wont it already be normalized tho
if you are just adding 1
then its already normalized
right?
i dont think so
normalizing when having 1, 1
is like 0.707, 0.707
rlly?
u can normalize at 1,1?
🤣
is there any other way to rotate a player with direction
you can set the up and right of the transform too
you can use lookrotation i think
and do make it smooth you can lerp it
sure why not