#Snowball Hit
1 messages · Page 1 of 1 (latest)
I was hoping the messages would load into this chat log
sec
SnowBall_hit https://gdl.space/ofimadoseh.cpp
Player_RayCast https://gdl.space/folaxonexi.cs
Both https://gdl.space/iyocaguzif.cs
Do you have any Errors in your code`?
I had some, but I removed them from the unity compiler
Removed how?
😆
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;
yes
Then have you fixed it?
I made this mistake on purpose to show the clear button
Alright.
Have you tried visualizing the RayCast?
Debug.DrawRay()
Debug.DrawLine()
no
where should I put it?
in Update
here?
yes
why is this a mistake?
DrawRay(start, direction, color, length)
DrawLine(start, end, color)
thx
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/
thx, you too 🙂
Thank you! But unfortunately I dont understand...
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
Thanks! but I don't understand how to implement it.
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
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;
}
}
}
You can see the Green Line coming out of the Snowball in Scene view
I understand, but how will it help me?
It will help you see precisely how the actual Raycast looks
and thereby making it easier to figure out why it is not behaving the way you want
Thanks! but I still don't understand why my snowballs don't reach the surface and why sometimes they fly through surfaces
What kind of scripts have you made for Unity so far?
Are you following a tutorial?
@warped patio
A little bit
I finished viewing, I did everything, but I have these problems
viewing what?
I watched the tutorial
which tutorial?
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?
I think so
Thanks, but I've reviewed it many times and rechecked it. At first I wrote this code myself, everything coincided, but just in case I downloaded its code from the description and inserted it into my project
Does it work then?
Works. but as I said, for some reason the snowballs do not reach the surface and sometimes fly through
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
how can I do this?
Give me a minute.
Also - are you using Rigidbody?
Where?