Author Topic: Can't get TNManager.CreateEx to work! UGH  (Read 2688 times)

Veraster

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 2
    • View Profile
Can't get TNManager.CreateEx to work! UGH
« on: August 17, 2015, 08:12:21 PM »
I'm having a problem where I can't get TNManager.CreateEx to make an object. After an excruciating 2 hours of working at it I still can't get it to work!
Here's my code:
  1. public void blahblahblah(){
  2.  
  3. TNManager.CreateEx(11, true, projectilePrefab, <position>, <rotation>, <someforcevector3variable>));
  4.  
  5. }
  6.  
  7.  
  8. [RCC(11)]
  9.     static GameObject OnCreate(GameObject prefab, Vector3 position, Quaternion rotation, Vector3 vel1)
  10.     {
  11.         GameObject go = Instantiate(prefab, pos, rot) as GameObject;
  12.         go.rigidbody2D.AddForce(vel1);
  13.         return go;
  14.  
  15.     }
  16.  

When I execute that code, nothing happens. I don't even get an error. However if I replace the above with the following code, it works just fine except it doesn't work for multiplayer:
  1. public void blahblahblah(){
  2. GameObject proj = Instantiate(projectilePrefab, <position>, <rotation>) as GameObject;
  3. proj.rigidbody2D.AddForce(some vector 3 force here);
  4.                         }
  5.  

Can anyone please help?

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: Can't get TNManager.CreateEx to work! UGH
« Reply #1 on: August 17, 2015, 10:46:09 PM »
only thing i can think of:

  1. void Awake()
  2. {
  3.      TNManager.AddRCCs<mono_component>();
  4. }
  5.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Can't get TNManager.CreateEx to work! UGH
« Reply #2 on: August 18, 2015, 05:48:43 PM »
Yup as devomage pointed out you likely just forgot to register your custom creation function with TNet.

Veraster

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Can't get TNManager.CreateEx to work! UGH
« Reply #3 on: August 18, 2015, 07:42:37 PM »
Hey thanks a lot! All I had to do was add the code that devomage posted and it worked  8)