- Home /
My RPC gets called, but doesn't do the math before it
So... I'm doing a script for onDeath. here's some variable definitions:
newestID = highest number connection that attacked the ownerID
ownerID = the 1001 multiple of the user (body mesh)
swordID = the 1004 multiple of the user (-3 to find the 1001 ID)
winnerID = the 1001 multiple of the user who did the most damage to ownerID
[RPC] private void success(){ if(hpWidth>0.0f){ hpWidth-=0.5f;
} else{ //------------------ for(int check = 1; check<newestID; check+=1000) {if(ownLog[check]>ownLog[winnerID]) winnerID=check; ownLog[check]=0; } Debug.Log ("winnerID:"+winnerID); //------------------ hpWidth=0.0f; swordW.particleSystem.renderer.enabled = false; player.renderer.enabled = false; swordS.renderer.enabled = false; swordW.renderer.enabled = false; swordW.collider.enabled = false; sheildW.renderer.enabled = false; sheilds.renderer.enabled = false; } }
All the enabled = false are working just fine... its the for statement I just cannot get to work. Any ideas?
all the ownLog, winnerID etc are public... after having tried private
The for loop is checking the numbers 1, 1001, 2001, 3001, etc. Is this what you meant to do?
Sorry... I meant to add that in there, Yes. The viewID's are assigned to 1001, 2001, 3001 etc... I'm hoping to get to 20 instances :P
It's just not obvious without code comments what ownLog
, newestID
and winnerID
are in the context your game and what their relationship is supposed to be, so I can't tell if there is something wrong with your script or what. All I can say for sure is throw more Debug.Log
s at it.
swordID is the collider's ID related to the collider's Owner's viewID (sword viewID is 1004, so swordID should be 1001) owner's ID is the body that was hit (being 2001 for example)
int[] ownLog should be the owner's array that tracks how many times swordID has hit the owner since the owner last respawned (ownLog[swordID]=8; means this swordID has done 8 hits to ownerID)
I have gotten a "winnerID=1" after I set winnerID=2; just under the else. So it seems like 5 runs through 10, but doesn't ever catch the loop statement? also, this only happens once if it happens at all.
Before the loop :
Debug.Log ("newestID: "+newestID);
Debug.Log ("winnerID: "+winnerID);
inside the loop:
Debug.Log ("check: "+check);
Debug.Log ("ownLog[check]: "+ownLog[check]);
On my way into work, I was thinking, if ownLog is public so everyone can see it, I'll probably need to make ownLog a 2-d Array?
ownLog[ownerID][swordID]
this way I can keep straight that ownerID was hit by swordID x times even if the ownerID switches.
As a private array, it should work as ownLog[swordID]... right?
Your answer
Follow this Question
Related Questions
Inventory adds an item only once. 0 Answers
Crushing Character 2 Answers
Very simple collision death 1 Answer
Yield Continuous Death 1 Answer
the "in" Syntax 1 Answer