Quantcast
Channel: Latest Questions by Turkeybag
Viewing all articles
Browse latest Browse all 27

Calling a function in another script not working with yield

$
0
0
Alright so upon finding out sendmessage can only send 1 parameter I found an alternative: InstantForce = Target.GetComponent("CharacterMovement"); InstantForce.InstantForce(100.0, ExplosionDirection); I want it to pretty much start the function "InstantForce" in my CharacterMovement script. It does this although my old yield in a for loop trick doesn't work. function InstantForce (Length : float, ApplyForce : Vector3) { for (var A = Length; A > 0; A--) { rigidbody.AddForce(ApplyForce*(A/Length), ForceMode.Impulse); yield new WaitForFixedUpdate(); Debug.Log(A); } } It dubugs 100 once when I move the debug above the yield but comes up blank while it's there. I think it's something to do with the way I'm calling it? If so what's the fix? I'm clueless! EDIT: This works if I call it instead of InstantForce but it just seems so pointless! There has to be another way? function ApplyInstantForce (Length : float, ApplyForce : Vector3) { InstantForce(Length, ApplyForce); }

Viewing all articles
Browse latest Browse all 27

Trending Articles