Author Topic: SGSK - Tnet animation question  (Read 3210 times)

emachala

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
SGSK - Tnet animation question
« on: September 30, 2014, 03:09:47 PM »
Added my new ships via selectors via main menu. wanted to setup first animation working over tnet, since i tested them via my old JS. cant seem to get them working over tnet yet  what my issue? tried it a number of ways.. Going to pull apart my ui kit i got yesterday for tnet and ngui maybe add some more insight for me.


js play single animation on key press
  1. var PowerOn : AnimationClip;
  2.  
  3. function Start() {
  4.  
  5. }
  6.  
  7. function Update() {
  8.    if( Input.GetKeyDown(KeyCode.k) ) {
  9.       animation.Play("LandingGearsDown01");
  10.       audio.Play();
  11.    }
  12. }

C# play single animation on key press over tnet
  1. using UnityEngine;
  2. using TNet;
  3.  
  4. public class ShipAnimations : TNBehaviour
  5. {
  6.         // Use this for initialization
  7.         void Start () {
  8.         }
  9.        
  10.         // Update is called once per frame
  11.         void Update () {
  12.           if (tno.isMine)
  13.         {      
  14.           if (Input.GetKeyDown(KeyCode.K))
  15.           tno.Send("Play", Target.All);  
  16.         }  
  17.     }
  18.   [RFC] void Play() {
  19.      animation.Play("LandingGearsDown01");
  20.     }
  21.  
  22. }
  23.  
  24.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: SGSK - Tnet animation question
« Reply #1 on: October 01, 2014, 05:34:44 PM »
What you're doing is fine. You're checking to see if you own the object, and if so you check for input and execute the Play() function on all connected clients. It should work both online and offline.

emachala

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: SGSK - Tnet animation question
« Reply #2 on: October 01, 2014, 09:14:45 PM »
ah yes noobish mistake didnt realize a tn object was needed again on Hull inside Starship.prefab.

Thanks  i edited script in mono and didnt add it drop menu so didn add the tnobject auto.

Works perfect