Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - r6834

Pages: [1]
1
NGUI 3 Support / NGUI slider jumping to wrong value..
« on: September 04, 2014, 06:47:04 PM »
So I am trying to place an NGUI slider under a panel in 3d space. It works for the most part, but if I disable the the collider on the background object, the slider gets crazy. It jumps from 0 to 1 when I click on it instead of letting me drag it smoothly. It seems I can do this in 2d space just fine, but when I make the slider a child of my 3d panel is when it starts snapping to full on the first click. I have been at this for hours now, has anyone else experienced this sort of thing?

2
What is the best approach for building your character input system on top of NGUI, then sending commands from NGUI buttons and widgets to your own player over the network?

Would you want to create the UI like most other network objects at the game start?

Is it necessary to have your controller script send your own players commands over the network, or is it best to just send the results from that input command to the rest of the room?

What is the best way to reference and send commands to your own player?

Currently, I have it working pretty well like this, but I want to understand if this is the right approach.

My input handler script attached to an NGUI widget that lives in the scene :
  1. var myPlayer : GameObject;
  2.  
  3. function Start () {
  4.        
  5. }
  6.  
  7. function OnClick () {
  8.                
  9.                 var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
  10.                 var hit : RaycastHit;
  11.                        
  12.                 Debug.Log("click");
  13.                          
  14.                 if (Physics.Raycast (ray, hit, 100)) {
  15.                                
  16.                         if (hit.collider.gameObject.layer == 9) {
  17.                                        
  18.                                 var targetPoint = hit.point;
  19.                                 var myTno = myPlayer.GetComponent(TNObject);
  20.                                 myTno.Send("OnSetTarget", TNet.Target.AllSaved, targetPoint);
  21.                                        
  22.                         }
  23.                                
  24.                 }
  25.  
  26. }

My character controller script :
  1. #pragma strict
  2. var targetPos : Vector3;
  3. var tno : TNObject;
  4. var myController : TouchHandler;
  5.  
  6. function Start () {
  7.  
  8.         tno = gameObject.GetComponent.<TNObject>();
  9.         targetPos = transform.position;
  10.        
  11.         if (tno.isMine) {
  12.        
  13.                 myController = GameObject.Find("LookArea").GetComponent(TouchHandler);
  14.                 myController.myPlayer = gameObject;
  15.  
  16.         }
  17. }
  18.  
  19. @TNet.RFC
  20. function OnSetTarget (tar) {
  21.  
  22.         transform.position = tar;
  23.  
  24. }

3
TNet 3 Support / Updating a players position OnNetworkPlayerJoin
« on: April 05, 2014, 02:58:50 AM »
Hi, I am new to TNet and I am trying to figure out some of the basics. So far it has been a great asset for a beginner. Following some of the examples, I was trying to update a previous players positions during an "OnNetworkPlayerJoin" function call. I am not getting anything at all. Can anyone show me where I may be overlooking things? Thanks for the help.

  1. #pragma strict
  2. private var agent : NavMeshAgent;
  3. var tno : TNObject;
  4.  
  5.  
  6. function Start () {
  7.  
  8.         agent = GetComponent.<NavMeshAgent>();
  9.         tno = GetComponent.<TNObject>();
  10.  
  11. }
  12.  
  13. function Update () {
  14.  
  15.         if (tno.isMine) {
  16.                 var hit: RaycastHit;
  17.                 if (Input.GetMouseButtonDown(0)) {
  18.                
  19.                         var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  20.                                
  21.                         if (Physics.Raycast(ray, hit)) {
  22.                                 tno.Send("SetTarget", TNet.Target.All, hit.point);
  23.                         }
  24.                 }
  25.         }
  26.  
  27. }
  28.  
  29. function OnNetworkPlayerJoin() {
  30.  
  31.         tno.Send("SetTargetImmediate", TNManager.player, transform.position);
  32.  
  33. }
  34.  
  35. @TNet.RFC
  36. function SetTarget (tar) {
  37.  
  38.         agent.SetDestination(tar);
  39.  
  40. }
  41.  
  42. @TNet.RFC
  43. function SetTargetImmediate (pos : Vector3) {
  44.  
  45.         transform.position = pos;
  46.  
  47. }
  48.  

Pages: [1]