#lets make a thread

1 messages · Page 1 of 1 (latest)

real cliff
#

is it done?

#

ok cool

half raptor
#

yea

real cliff
#

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

half raptor
real cliff
#

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

half raptor
#

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

real cliff
#

no that's fine, i'd just like to discuss it a bit since im not sure i understand it all

half raptor
#

sure

real cliff
#

how does the object know to move to the next position?

#

is it based on the .distance?

half raptor
#

think of it as i in a for loop

real cliff
#

yeah that's what i thought that was

half raptor
#

just madeup number 0.2f

real cliff
#

thats the distance threshold right?

half raptor
#

so like if it gets that close it switches to next one

#

yea

real cliff
#

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

half raptor
#

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

real cliff
half raptor
#

do you know what ++ does ?

real cliff
#

yeah, it essentially just adds 1 to the current value

half raptor
#

yea so

#

the index is increasing

real cliff
#

wait do you mean increasing?

#

you had me so confused i thought that was a whole new word i didn't know

half raptor
#

nah my keyboard sometimes just stops working mid typing

real cliff
#

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?

half raptor
#

probably just adding a break there yeah

#

like else

#

if (currentPoint < points.Length - 1)
{
currentPoint++;
}
else
{
break;
}

real cliff
#

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?

half raptor
#

Im here for a bit but , if im not around do post in the code channel again with full code