Change FPS demo enemy's prefab to another

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

alexis75
Posts: 2
Joined: 06 Dec 2011, 21:40
Location: sweden

Change FPS demo enemy's prefab to another

Postby alexis75 » 06 Dec 2011, 22:23

Hi,
I am currently working on my multiplayer game based on SFS2X and FPS demo. Everything works fine on a simple bases, really great DEMO!

However, I have a question about enemy Prefab:
what is a proper way to change it to some other? I have some characters I have bought from a third party, they all have animations, etc
works very nice in a single player game.
But when I tried to recreate an Enemy Prefab, using logic and structure from the one in the FPS demo, it just does not work 100%.

What works:
-I can make a new Enemy prefab with my caharacter,
-when multiplayer game starts, both local and remote players are visible and moving, but 'frozen'..

Not working:
-animations that my character has, does not work at all ?..

I really tried different ways to connect my animations to new Enemy Prefab, but it just does not react.
If I understand right the only places one handle the animations are in
AnimationSynchronizer.cs and WalkController.cs or am I missing something? It should be quite easy based on the existing prefab.

Does character animations must be in some specific folder? I have them in an imported own folder, from there I drag & drop every needed animation onto Enemy Prefabs 'Hero' sublevel as in 'default'..


I will greately appreciate any help or tips to my problem, thank you!
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 07 Dec 2011, 10:34

Hmmm - hard to debug completely remotely. But you make the enemy prefab anywhere you like and then link it into the game scene, Game object in the Player Manager component as "Enemy Prefab".

That should spawn it.

Regarding animations - the AnimationSynchronizer handles it all by animation name. Maybe those changed on your enemy (most likely) - or the models Animations array doesnt contain the animations needed?

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
alexis75
Posts: 2
Joined: 06 Dec 2011, 21:40
Location: sweden

Did worked with animations

Postby alexis75 » 11 Dec 2011, 20:54

Thanks Thomas!
I followed your advice and it did worked with animations. Great!!

It turned out that even some other Enemy Prefab must have at least 6 animations, may be 4.. otherwise one has to adjust codes, perhaps both in .CS files and java extension.
But at least my character now moves, jumps and so on, according to its own animations.

However, I could not actually remove the 'AimStraight' animation, could you, please, tell me why it is so? As soon as I remove it, my character goes crazy :) twichning and scaling, etc

Is it because that just 'AimStraight' is in Blend mode and it's in another Layer=5? other animation have Layer=1 or =2 + Additive

Is there any way to remove/block 'AimStraight'? What I need for my game is a simple Idle animation as start/Init, and then some others when user make an Input.

//Alexis
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 14 Dec 2011, 10:54

Cant remember the specifics here - sorry. Been a while.

I think that part is something in the example code itself. Finding all usages there, replacing them with idle instead and setting up blending/layers correctly would be the way to go.

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games

Follow on twitter: http://twitter.com/thomas_h_lund
alaindum
Posts: 8
Joined: 03 Apr 2012, 17:23

Re: Change FPS demo enemy's prefab to another

Postby alaindum » 03 Apr 2012, 17:34

Hello,

I tried the same way
I started from the FPS example,
I added a chat in,
I tested with friends and it is OK.

But I wanted to change the enemy prefab.

When there is no amimation it is ok too,

Image

but when I put in the enemy a fbx with walk etc ,

the result is crappy.

Image


I used several prefabs, I changed several time the animationsynch scrip to match them ,
but I am lost now ..

Any help please ?
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Re: Change FPS demo enemy's prefab to another

Postby ThomasLund » 06 Apr 2012, 10:18

Best guess is that your new models dont work with the animation files that are run.

The FPS example uses the same model and same animation files for both you and enemies. Changing one of the models and having it use the animations from the player - could give very very interesting animation artifacts.

I'm not a 3d animator - but I've seen the results myself. Bone structures and animation files have to match.

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games

Follow on twitter: http://twitter.com/thomas_h_lund
alaindum
Posts: 8
Joined: 03 Apr 2012, 17:23

Re: Change FPS demo enemy's prefab to another

Postby alaindum » 07 Apr 2012, 19:42

OK, thank you Thomas,
and if I undersand you well ,
you guess I have problems with the models I use.
And I tried several with the same result : crappy distorsions.
My last test was with the Male found in the "CharacterCustomization" unity 3d example.
And I guess the model and his animations are OK.
But for me same crappy results.

Image
So I guess that the problem is how I make the prefabs ...

Image
I added all the sripts needed,
I dont know what to check more ....


reedit :

to be clear , and scuse my english if I am not ,
what I want to do is to change the player/enemy in that sort of chat I made from the SFS example :

http://mixed3d.free.fr/unity3d/2012/fps ... layer.html
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Re: Change FPS demo enemy's prefab to another

Postby ThomasLund » 14 Apr 2012, 08:31

Hi - its not necessarily the model itself - but the model in combination with the animations that are made for a different model (the default one).

When you change the model in the enemy prefab, you need to make sure to add animations that are made for THAT character model. And not reuse the animations made for the Unity example character. I'm talking the animations that are seen in the attached screenshot.

Screen Shot 2012-04-14 at 10.17.13.png
(55.49 KiB) Not downloaded yet


Thats the first part. The animations need to be made for the model you are using - or with the exact same bone structure. (I'm not a modeller, so I cant tell you the details as I dont understand it all either).

Next up are some of the code parts that you need to look at.

In the client code it expects animation names to be of similar names and layered:

Example from NetworkManager in the HandleShotFired method. Here it has from the server received, that the remote player fired a shot = we need to animate the remote avatar with the "Shot" animation playing in animation layer 1:

Code: Select all

   PlayerManager.Instance.SyncAnimation(userId, "Shot", 1);


So if your new character doesnt have an animation named "Shot" then that will fail to play. And since the AnimationSynchronizer script sets up layers with blending, one also needs to make certain that the new character works similar (or rework the layers/blend modes in the AnimationSynchronizer code).

So to sum up:
- make certain that you are not trying to use new model with old model animation files
- make certain that animations are called the same and/or rework the code to use the new model animation file names
- make certain that the AnimationSynchronizer code layer/blending is set up correct for your new model and the new animations. Especially check InitAnimations() method.

Hope that helps!

/T
Full Control - maker of Unity/C# and Java SFS API and indie games

Follow on twitter: http://twitter.com/thomas_h_lund
alaindum
Posts: 8
Joined: 03 Apr 2012, 17:23

Re: Change FPS demo enemy's prefab to another

Postby alaindum » 16 Apr 2012, 19:36

sure that helps !

Thank you very much, Thomas.
Indeed I thought I did before , more or less, how you say,
but of course I made errors ,
so I re checked all , re checked , re checked,
and now I am on the way ..

I tested online with a friend,
he walks, and idle.
I deleted all the shoot stuff,
sorry LOL but it is my way to learn,
going from complicated ( for me ) to more simple ...

Anyways I have still some small probs ,with the animations,
the "hide/show cursor" etc.

I think I will fix them...

Re merci !

If I have that sort of simple chat MMO I wanted since ages ( 2 years working on LOL)
my next step will be the "avatar" customization for "visitors" ( that will need 4 years :)


http://mixed3d.free.fr/unity3d/2012/fps/zombiprint.jpg

http://mixed3d.free.fr/unity3d/2012/fps/zombiprint2.jpg
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Re: Change FPS demo enemy's prefab to another

Postby ThomasLund » 16 Apr 2012, 21:29

Super

Check out the latest example 4 I did - doesnt use server side extensions, but it shows how you can simply set and read avatar model+material using user variables

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games

Follow on twitter: http://twitter.com/thomas_h_lund
alaindum
Posts: 8
Joined: 03 Apr 2012, 17:23

Re: Change FPS demo enemy's prefab to another

Postby alaindum » 16 Apr 2012, 22:22

ah ! super too ! :)
I will learn from , thank you.

BTw I fixed the cursor prob , I must get the right anims now.

moment ... :)
alaindum
Posts: 8
Joined: 03 Apr 2012, 17:23

Re: Change FPS demo enemy's prefab to another

Postby alaindum » 16 Apr 2012, 22:41

wow sounds nice ! :)

Image
alaindum
Posts: 8
Joined: 03 Apr 2012, 17:23

Re: Change FPS demo enemy's prefab to another

Postby alaindum » 18 Apr 2012, 13:33

Hi Thomas and all,

I have bad news and good news.

Bad : I still have probs to correctly anim my player and my enemy
( they walk bad)
( and no name over the head)

BUT ,

to have some rest I re tried your "select your model" example, Thomas.
It is very good !!!

I replaced the capsule by a character , I used a "moving.js" scipt on it,

and when I choose the capsule model I walk and jump !

That took me 4 minutes and not 4 years !! :)

Merci beaucoup !!! I will continue to play with all that !


Image

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 58 guests