#AnonymousCoder

1 messages · Page 1 of 1 (latest)

sharp kettle
kind lodge
#

uh why did a thread start wait nvm

sharp kettle
#

So you're saying the raycast hits the floor correctly with the parameters I gave you or the ones you used

kind lodge
#

uh the ones I used

sharp kettle
#

because -Vector2.up is technically correct, it's kind of weird considering there's Vector2.down

kind lodge
#

I converted it but it still doesn't work

sharp kettle
#

Whats the problem exactly?

kind lodge
#

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

sharp kettle
#

How big is your player?

kind lodge
#

0.75 units

#

in width and height

sharp kettle
#

can you lower the opacity on your player? and take the ss again

kind lodge
sharp kettle
#

Is your player scaled?

kind lodge
#

no

sharp kettle
#

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?

kind lodge
#

yes

#

its a child of the scene only

sharp kettle
#

so you gave a width and height, is your player a UI element?

#

or did you just give the resolution of the sprite

kind lodge
sharp kettle
#

Ok can you try a value of 0.25 in the raycast for me

kind lodge
#

sure

sharp kettle
#

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

kind lodge
#

so should the size be something about half of the height of the player

sharp kettle
#

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

sharp kettle
#

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)

kind lodge
#

for some reason its still not working tho

sharp kettle
#

check the ground collider

kind lodge
#

yeah it looks okay

sharp kettle
#

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)

sharp kettle
#

have you tried a box collider yet?

kind lodge
#

added a box collider but looks to be false still in the debug

sharp kettle
#

that's strange

kind lodge
#

yea

sharp kettle
#

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?

kind lodge
#

no

sharp kettle
#

Try doing that

#

I havent used Vector2.down but I assume the Z position still affects it

kind lodge
sharp kettle
#

So they are on the same Z?

kind lodge
#

actually lemme send the raycast code just in case im not doing it right

sharp kettle
#

Alright

kind lodge
sharp kettle
#

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

kind lodge
#

yeah it still doesn't work

sharp kettle
#

can you send the full script

kind lodge
sharp kettle
#

Try vector3 instead of vector2

kind lodge
#

still printing false for the if condition interesting

sharp kettle
#

Your player is colliding with the ground correct?

#

Like, the physics end works correctly

kind lodge
#

it was working before

#

im looking at the documentation and I wonder if this might effect anything

sharp kettle
#

oh my god

#

ok wait i think i figured it out

#

Physics2D not Physics

kind lodge
#

cool

#

OH

#

WAIT IT WORKS I THINK

sharp kettle
#

Can I ask why you have a variable for touching walls and which way the player is touching a wall

kind lodge
sharp kettle
sharp kettle
#

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

sharp kettle
#

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

kind lodge
#

ok

#

uh my character occasionally jumps in midair