#Snowball Hit

1 messages · Page 1 of 1 (latest)

warped patio
#

I was hoping the messages would load into this chat log

#

sec

#

Do you have any Errors in your code`?

cerulean valley
warped patio
#

Removed how?

cerulean valley
#

😆

warped patio
#

I have 6 minutes till my morning meeting starts.

#

I believe these two lines would have the same effect.

transform.TransformDirection(Vector3.forward);
transform.forward;
cerulean valley
warped patio
#

that's just Clearing the console

#

Do you know what the error means?

cerulean valley
#

yes

warped patio
#

Then have you fixed it?

cerulean valley
#

I made this mistake on purpose to show the clear button

warped patio
#

Alright.

#

Have you tried visualizing the RayCast?

#

Debug.DrawRay()
Debug.DrawLine()

cerulean valley
cerulean valley
warped patio
#

in Update

cerulean valley
warped patio
#

yes

cerulean valley
#

why is this a mistake?

warped patio
#

DrawRay(start, direction, color, length)
DrawLine(start, end, color)

cerulean valley
#

thx

warped patio
#

as long as you choose the right one, compared to your original approach
it should take the same parameters, and thus be a true representation of the actual Raycast

#

I have to run. Good luck o/

cerulean valley
#

thx, you too 🙂

cerulean valley
tired hare
#

if you use the same start/end or the same start/direction/length as your linecast/raycast, drawray/drawline will draw a ray/line visually that represents what your raycast/linecast is doing.
so you can actually see where your cast is going and go from there @cerulean valley

cerulean valley
tired hare
#

you're doing a raycast already

#

the first position [transform.position] is the start position

#

the 2nd thing is the direction [the vector3 forward bit]

#

the number at the end [100] is the length of the ray

#

hence, DrawRay(transform.position,the forward thingy,Color.red,100)

#

something along those lines

#

Color.red is just the color for the ray. it's just to help you debug so you can see if the ray is going the way you want it to

warped patio
# cerulean valley Thanks! but I don't understand how to implement it.
void Update()
{
    Vector3 start = transform.position;
    Vector3 direction = transform.forward;
    float length = 100f;

    Debug.DrawRay(start, direction, Color.green);

    if (onhit == true)
    {
        RaycastHit hit;
        if (Physics.Raycast(start, direction, out hit, length))
        {
            SnowBall_hit.transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
            onhit = false;
        }
    }
}
cerulean valley
#

Thanks! but what does it give?

#

@warped patio

warped patio
cerulean valley
warped patio
cerulean valley
warped patio
warped patio
#

be specific

#

I need to know what level you're at

cerulean valley
warped patio
#

viewing what?

cerulean valley
warped patio
#

which tutorial?

warped patio
#

When it comes to tutorials, the best you can do is watch it at least 2 times, and then post link and timestamps to things you have issues with.

When following a tutorial, it is best to name variables the same as in the tutorial, so you can easily check if your code is the same.

#

Also read the comments

#

I'm not sure if I can help you with that specific tutorial, since it is in Russian; unless I can fully understand what the code segment is supposed to do.
Is it possible for you to follow an English speaking tutorial?

cerulean valley
warped patio
#

Does it work then?

cerulean valley
warped patio
#

Make sure your Layers are structured properly

#

if you're implementing this into an existing project
perhaps make a new project, and see if you can work out the basics there

cerulean valley
warped patio
#

Give me a minute.
Also - are you using Rigidbody?

cerulean valley
#

Where?

warped patio
#

do the snowballs have a rigidbody?

#

or a collider