hello, all
working, on a single problem to be sorted out for couple of days, so please help me in this.
The thing is the animation is trigerring by self. Now for the description, here it goes…
Set up the game assets and scripts and also with reference to networking example. Now the character animations are setup on the character. Like for idle, reaction, punch etc. And all of which are working fine.
And the empty game objects are set with the colliders, for the area of face and hand. The thing is when the punch animation is fired and the other characters face collider detects that and fires the reaction animation. Upto this it works good. But the problem is the character hitting the pucnch is also firing the event of reaction to itself also, which shouldn’t happen. This also happens in the networking multiplayer mode also, Actually the main problem is its happening in networking and the game is for multiplayer base.
While all the things and scripts are working fine for run, idle, etc animations.
For this i have make .enabled = false in the networkinit script so couldn’t find the right way out.
Also work in various manner to work the scripts properly but the same things are still happening.
The colliders on both objects will fire an OnCollisionEnter event when they make contact. A parameter of type Collision is passed to this function - one of the properties of this type tells you which collider was hit. If you check this you should be able to detect which collider was hit (ie, face, hand, etc) and on which object. Once you know that, you can arrange it so that the reaction animation doesn’t get played for the character who is punching.
yaa, you are at the right point where i am stuck.
Thanks.
But still i couldn’t find out for how can i manage with the collision thing, like the instantiate is done for the same player character that i am having. And so the same name collider are there in the other player like its instantiated from the same prefab in the network.
So, how can be the collider name different as i have place two empty game object with colliders (face and hand). and triggering the OnEnter events while the hand collider touches the face collider.
The collider name itself may be the same, but the Collision object also has gameObject and transform properties. Perhaps the best way to go is to use the transform.root property to get the top-level object of the character. You can then get its name, etc, and identify it like that.
Actually the main Character prefab is there.
for e.g charOne
and it has the child objects with box collider
like face and hand
So, the main character prefab is instantiated while starting game, and in network while getting connected its again clones from the same charOne place as prefab in the project panel
So, the other clone player is having the same heirarchy and name as i checked in the unity editor itself.
And if its still possible to get some id from the colliders or the way you say. But please describe for the same as not able to get the straight out from the thing transform.root that you told about.
transform.root of no use OR how can it be used.
here is the script i using
function OnTriggerEnter(other : Collider)
{
if(other.gameObject.tag == "punchHit")
{
MixingCrossfadeChar.charHit = true;
}
}
Couldn’t find the right solution still.
Now going for increase in radius of character controller and its settings, so that the other characters reaction animation doesn’t pierce in mine character, As like both the character doesn’t comes too close now.
As per the say its not the right way.
Still needed to sort it in proper manner instead of this low common solution.
Any help please advice
Are you using a CharacterController to detect the face punch? If so, and the face is in the top dome of the capsule collider, then there might be a problem. It appears that this doesn’t always register collisions as it should.
Character collider i am using only for physics gravity stuff and to controll the character walk, and by using the scripts attached to the character.
As, added the two child objects with box collider
for e.g named as face and hand
and the script i attached to face game object that i mentioned above… in this post
in that it checks for the hand gameobject like mentioned as “punchHit” , in the script also its there
and this triggers the true event (for charHit) in the script attached to the main character, There its the update function checking to get the condition true and firrrreee the reaction animation event.
hope its now understandable
So, now how can i proceeed with this further in regards to my prob
Thanks
OK, another possibility is to rename the clones as they are created. Keep an integer variable in the script that instantiates the clones, add its value to the clones’ names and increment it each time a new clone is created:-
var objectCount: int;
...
newObject = Instantiate(...);
newObject.name += objectCount.ToString();
objectCount++;
Then, when the collisions happen, you will be sure that each object has a unique name to identify it.
:?
Not tried it but, going to work on it.
As previously did this, may be was not in a suitable manner.
Again i will give this a try.
As the characters are already having with different prefabs so i doubt it but should try again, since they are instatiating with a clone name.
I need to achieve the proper way to get the results for the work, as already most of time is went on this. And still stuck in this.