#lets make a thread
1 messages · Page 1 of 1 (latest)
yea
so basically i have a lock on system that gets the all the objects that have been caught by a ray while the right click is held down, once right click is released, the ball must fly to all the positions that were caught by the ray and put into a list
thats why i thought a for loop made sense, as it would go to a position for every object in the list
how do you plan on moving the ball towards them
not sure yet, i want the movement to be visible but fast
kind of like in mario odyssey when you possess the power lines, if you've seen that
i thought of using MoveTowards since it uses vector3's
just an idea maybe something like this cs Transform[] points; int currentPoint = 0; IEnumerator Move() { while (true) { if(Vector3.Distance(transform.position, points[currentPoint].position) < 0.2f) { if(currentPoint < points.Length-1) { currentPoint++; } } float T = speed * Time.deltaTime; transform.position = Vector3.MoveTowards(transform.position, points[currentPoint].position, T); yield return null; } }
didn't test just yet not at pc atm
no that's fine, i'd just like to discuss it a bit since im not sure i understand it all
sure
currentPoint is a tracking of index
think of it as i in a for loop
yeah that's what i thought that was
just madeup number 0.2f
thats the distance threshold right?
ok so
while true, the ball will move to the position of the current point in the list, and when it does will know to move to the next one because of currentPoint++
and it will do this until currentPoint is no longer less than the length of the points list
only the increasing
i didnt put a way to break out the loop because i dont know ur exact case lol
so technically when it reaches last point it just stays there
what is incerasing?
do you know what ++ does ?
yeah, it essentially just adds 1 to the current value
wait do you mean increasing?
you had me so confused i thought that was a whole new word i didn't know
nah my keyboard sometimes just stops working mid typing
ah no worries
so how would it break out of the loop? Does it just need an else when currentPoint is the same as the list length?
probably just adding a break there yeah
like else
if (currentPoint < points.Length - 1)
{
currentPoint++;
}
else
{
break;
}
alright, I'll try and work that into my code since I think i get it now. Are you alright to help out a bit more if i get stuck?
Im here for a bit but , if im not around do post in the code channel again with full code