#AnonymousCoder
1 messages · Page 1 of 1 (latest)
uh why did a thread start wait nvm
So you're saying the raycast hits the floor correctly with the parameters I gave you or the ones you used
uh the ones I used
because -Vector2.up is technically correct, it's kind of weird considering there's Vector2.down
oh
I converted it but it still doesn't work
Whats the problem exactly?
unless im misunderstanding how it works
so basically im trying to make the player jump but the raycast doesn't work
this is what happens when I draw the ray
I think I might be misunderstanding something
How big is your player?
can you lower the opacity on your player? and take the ss again
Is your player scaled?
no
So the player is not scaled (scale is equal to 1 1 1) and the player is not a child of any transforms that are scaled?
so you gave a width and height, is your player a UI element?
or did you just give the resolution of the sprite
its a game object
Ok can you try a value of 0.25 in the raycast for me
sure
the solution to this is basically trial and error but it looks like to me you don't know what the actual size (to unity) that your player is
ah
so should the size be something about half of the height of the player
yes
you could also make a "Feet" gameobject to the bottom of your player or something to send the raycast out from instead so you don't have to do anything besides just sending a raycast out
In that case you could just set the distance to a very very small number
like 0.01?
yeah a number small enough so that the player would never notice
because you dont want the player to be able to jump before they're actually on the ground (unless maybe you want to do that to make the game easier)
true
for some reason its still not working tho
check the ground collider
yeah it looks okay
try using a box collider
raycasts may not like edge colliders
oh, also, in your code I noticed you were doing tag comparisons
collision.gameObject.tag == "Wall" && collision.gameObject.name.Contains("Left")
use CompareTag(string tag) instead (its faster)
ok
have you tried a box collider yet?
added a box collider but looks to be false still in the debug
that's strange
yea
and would it still be false if you put "1" as the distance?
i think i remember that it was going through the platform before
are your player and the platforms on the same Z position?
no
Try doing that
I havent used Vector2.down but I assume the Z position still affects it
So they are on the same Z?
actually lemme send the raycast code just in case im not doing it right
Alright
comment out that if statement and just make an if(raycast)
the problem with having a bunch of conditions in an if statement is that it makes debugging them a pita
yeah it still doesn't work
can you send the full script
Try vector3 instead of vector2
still printing false for the if condition interesting
Your player is colliding with the ground correct?
Like, the physics end works correctly
yes
it was working before
im looking at the documentation and I wonder if this might effect anything
Can I ask why you have a variable for touching walls and which way the player is touching a wall
its so that the character doesn't move if facing a certain direction
So the player doesn't go through a wall?
yea
Well a box collider for your platforms would do that better
At line 130
if(transform.position.y < -7.5)
{
GameObject.Find("GameManager").GetComponent<GameManager>().GameOver();
}
Make a variable for your GameManager and find the GameManager at the start of the game and set the variable to it
NEVER use GameObject.Find in Update or FixedUpdate
If you type
public GameManager gameManager;
in your script, you'll be able to drag the game manager in your scene into the player
in the inspector*
So you wont have to type Find GetComponent blah blah everytime you want to do something with the game manager
you just type gameManager.GameOver() or whatever you want