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.


Messages - Danim3D

Pages: [1]
1
NGUI 3 Support / Re: Simulate Mouse click Button on Key Input
« on: August 14, 2015, 02:48:59 PM »
Thank, it work  :D

2
NGUI 3 Support / Simulate Mouse click Button on Key Input
« on: August 13, 2015, 06:06:52 PM »
I am trying to Simulate a Mouse click on an NGUI Button with a Keyboard Input.

I have try the UIKeyBinding script and this line bellow but the UIPlayAnimation and fonction doesn't execute, only the sound play.
I would like to know what I'm doing wrong. Thank!

if(Input.GetKeyUp(KeyCode.Escape))
      buttonGameObject.SendMessage("OnClick", SendMessageOptions.DontRequireReceiver);

3
TNet 3 Support / Re: How to Sync 2D Toolkit Current Animation
« on: August 07, 2014, 04:25:57 PM »
Thank, it is an interesting way of doing the character movement direction from left to right. I got rid of all my code happening in FixedUpdate() fonction and use your solution. I did a test with just a moving cube and it is moving smoothly. My character with Rigidbody still have a little weird motion only when the second character Join, but it does look a lot better than before. Should I always use TNSyncRigidbody script with Rigidbody object? Currently I use it on my GamePlayer with Update Per Second at 1 only.

I am confuse about why you use  if (!tno.isMine)  instead of   if (tno.isMine)  and why we do move the target using the mDir value outside of if(tno.isMine) ? I understand the use of tno.isMine for Player but for Enemy should I use this as well if I don't want them to spawn in double.

I have to think differently about my jump code. What will be the best to sync for the jump? Should I sync the key Input.GetKeyDown, the position.y or the rigidbody velocity? What will happen if the character start to jump and the position is being sync in the middle of the jump, will the jump stop syncing? Should I sync as well the grounded and doubleJump state as well? I use something like this:

  1. if(Physics.Raycast(thisTransform.position, raycastDir, 1f)) {
  2.         if(!grounded){
  3.                 grounded = true;
  4.                 doubleJump = false;
  5.         }
  6. }else{
  7.         grounded = false;
  8. }
  9.  
  10. if(Input.GetKeyDown("space")){
  11.         if(grounded)
  12.                 rigidbody.velocity = new Vector3(0f,jumpHeight,0f);
  13.         if(!grounded && !doubleJump){
  14.                 doubleJump = true;
  15.                 rigidbody.velocity = new Vector3(0f,jumpHeight,0f);
  16. }

I tried this solution and it seem to work
  1.         [RFC]
  2.         void SetPosY(float jumpHeight){
  3.                 rigidbody.velocity = new Vector3(0f,jumpHeight,0f);
  4.         }

Tutorial 2 was very great to explain TNet, it would be great to do a video tutorial about the key press sync for character movement since it is a very different approach when we have to consider networking.
Thank!

4
TNet 3 Support / Re: How to Sync 2D Toolkit Current Animation
« on: August 05, 2014, 04:34:45 PM »
Input.GetKeyDown is now doing the animation.Play change and it is working well without TNAutoSync script.
But I still have to use Input.GetKey to keep moving the character in one direction while the key is press.
I could not get the Player position to move smoothly, I always get strange gap in the motion.

Here is what my code look like:

  1.         public Vector3 target{
  2.                 set{
  3.                         tno.Send(5, TNet.Target.AllSaved, value);
  4.                 }
  5.         }
  6.  
  7.         void Update(){
  8.                 if(tno.isMine){
  9.                         if(Input.anyKey)
  10.                                 target = transform.position;
  11.                         if(Input.GetKey("left"))
  12.                                 moveDir = -1;
  13.                         if(Input.GetKey("right"))
  14.                                 moveDir = 1;
  15.                         if(Input.GetKeyDown("left"))
  16.                                 currentAnim = "walkleft";
  17.                         if(Input.GetKeyDown("right"))
  18.                                 currentAnim = "walkright";
  19.                 }
  20.         }
  21.  
  22.         [RFC(5)]
  23.         void OnSetTarget(Vector3 pos){
  24.                 nTarget = pos;
  25.         }

I was expecting that target = transform.position; could sync the position but the character is not moving smoothly at all. The Player move well alone but as soon as the second player Join the motion has strange gap on both side for both Player. My Player Prefab has TNObject, TNSyncRigidBody script attach to it. TNAutoSync is not active but was not working for the transform.position either.
I have try to increase the TNSyncRigidBody to 20 Update Per Second which is probably too much but it is still not smooth.
Thank for any advices.

5
TNet 3 Support / How to access an object created with TNManager.Create?
« on: August 01, 2014, 02:50:54 PM »
When I use TNManager.Create
How do I access the object that I just created to change the name for example?
  1. TNManager.Create(Ball, pos, transform.rotation);

For example, when I use Instantiate I rename like this:
  1. GameObject myBall = (GameObject)Instantiate(Ball, pos, transform.rotation);
  2. myBall.name = "ChangedBallName";

I did try this but it give me an error:
  1. GameObject myBall = (GameObject)TNManager.Create(Ball, pos, transform.rotation);
  2. myBall.name = "ChangedBallName";

6
TNet 3 Support / How to Sync 2D Toolkit Current Animation
« on: July 31, 2014, 08:50:19 PM »
I'm trying to sync the current playing animation from 2D Toolkit.
It seem to try to sync only for the first frame of the clip than the animation flicker from walkleft to walkright.
I'm following the code structure show in Tutorial 2 and I came up with this:

  1.         public tk2dSpriteAnimator playerAnim;
  2.  
  3.         public string currentAnim{
  4.                 set{
  5.                         tno.Send(7, TNet.Target.AllSaved, value);
  6.                 }
  7.         }
  8.  
  9.         void Update(){
  10.                 if(Input.GetKey("left"))
  11.                         currentAnim = "walkleft";
  12.                 if(Input.GetKey("right"))
  13.                         currentAnim = "walkright";
  14.         }
  15.  
  16.         [RFC(7)]
  17.         void OnSetCurrentAnim(string currentAnim){
  18.                 playerAnim.Play(currentAnim);
  19.         }
  20.  

My animation is not sync with this code above but I it seem to work with the TNAutoSync script with my playerAnim variable.
I would appreciate tips to make it work in scripting.
Thanks

Pages: [1]