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 - BehindTheStone

Pages: 1 ... 7 8 [9]
121
NGUI 3 Support / Re: Permanent Button-Action
« on: January 10, 2013, 11:03:33 AM »
Hm. Now you mentioned it, it comes to my mind:

i have three different Movement-Buttons (Left, Right, Jump). I copy&pasted the code in order to make a seperate MoveLeft-Scipt and changed the variables (in order to make him move left actually :D ) and another to make him jump.

They have all the same structure.

  1. void Start ()
  2.         {
  3.                 knightObject = GameObject.FindGameObjectWithTag("Player");
  4.  
  5.                
  6.                
  7.                 KnightShape = knightObject.GetComponent<FSBodyComponent>().PhysicsBody;
  8.                 KnightShape.FixedRotation = true;
  9.                
  10.                 velocity = KnightShape.LinearVelocity;
  11.                 m_normal = new FVector2(1,0);
  12.                
  13.                 buttonDown = false;
  14.                
  15.        
  16.         }

And in OnPress(bool isDown) I check if it is pressed and set the buttonDown Variable to "true" so Update() can does its job.

Could that cause any problems? I tested it in the editor and the device and i didn't get strange behaviour (yet... :D ).

122
NGUI 3 Support / Re: Permanent Button-Action
« on: January 10, 2013, 10:20:46 AM »
Well yes, there are only 2 scripts which influence the Velocity (and one is only for testing things out), so i make sure that only one script is a component.

123
NGUI 3 Support / Re: Permanent Button-Action
« on: January 10, 2013, 10:10:06 AM »
Touché! :D

In the scene will be some Enemies, but the game's physics aren't "realistic" and it's way not physic-heavy like other games, so i think that should work quite well.

Well, thank you Cripple! :D

124
NGUI 3 Support / Re: Permanent Button-Action
« on: January 10, 2013, 10:04:35 AM »

Well, i did something like this:

  1. [...]
  2. private bool buttonDown; // which is set to "false" in Start();
  3. [...]
  4.  
  5. void FixedUpdate()
  6.         {
  7.                 if(buttonDown)
  8.                 {
  9.                         float velocityScale = 2.5f;
  10.                         velocity.Y = KnightShape.LinearVelocity.Y;
  11.                         velocity.X =  velocityScale * m_normal.X;
  12.                        
  13.                         KnightShape.LinearVelocity = velocity;
  14.                        
  15.                         Debug.Log("Moved");
  16.                 }
  17.         }
  18.        
  19.        
  20.         void OnPress (bool isDown)
  21.         {
  22.                 if(isDown)
  23.                 {
  24.                         buttonDown = true;     
  25.                 }              
  26.         }

And it worked :)

A little bit of a workaround, though. Another point is, that the developer of this PhysicsPlugin (Farseer-Port) mentioned on their blog that one should avoid FixedUpdate(), when developing for mobile devices (what i am doing right now) to get better performance :D

125
NGUI 3 Support / Re: Permanent Button-Action
« on: January 10, 2013, 09:49:46 AM »
So, i made just this:

  1. void OnPress (bool isDown)
  2.         {
  3.                 if(isDown)
  4.                 {
  5.                        
  6.                         float velocityScale = 2.5f;
  7.                         velocity.Y = KnightShape.LinearVelocity.Y;
  8.                         velocity.X =  velocityScale * m_normal.X;
  9.                        
  10.                         KnightShape.LinearVelocity = velocity;
  11.                        
  12.                         Debug.Log("Moved");
  13.                 }              
  14.         }

Hit RUN, and pushed the Button. Every single time he logged me "Moved". So, you're saying the physic code is wrong? Could you kind of point out what exactly could be wrong (i don't expect you to give me the perfect solution  :)  ), i' am just curious, because with the Keyboard-Input it works fine :/

- Yes, i am sure that i am not changing the Velocity with another script. There is only one script right one which influences any velocity, and it's attached to this Button.
- Forces. Yes, i will keep that in mind, thank you!

126
NGUI 3 Support / Re: Permanent Button-Action
« on: January 10, 2013, 09:28:07 AM »
Of course :)

  1. public class MoveRight : MonoBehaviour {
  2.  
  3.         private GameObject knightObject;
  4.        
  5.         // Farseer Bodies
  6.         private Body KnightShape;
  7.                
  8.        
  9.         //Farseer Vectors
  10.         private FVector2 velocity;
  11.         private FVector2 m_normal;
  12.        
  13.        
  14.        
  15.        
  16.         ///////////////
  17.         // Functions
  18.         ///////////////
  19.        
  20.  
  21.        
  22.         /// <summary>
  23.         /// Start this instance.
  24.         /// </summary>
  25.         void Start ()
  26.         {
  27.                 knightObject = GameObject.FindGameObjectWithTag("Player");
  28.  
  29.                
  30.                
  31.                 KnightShape = knightObject.GetComponent<FSBodyComponent>().PhysicsBody;
  32.                 KnightShape.FixedRotation = true;
  33.                
  34.                 velocity = KnightShape.LinearVelocity;
  35.                 m_normal = new FVector2(1,0);
  36.                
  37.        
  38.         }
  39.  
  40.        
  41.        
  42.         void OnPress (bool isDown)
  43.         {
  44.                 if(isDown)
  45.                 {
  46.                        
  47.                         float velocityScale = 2.5f;
  48.                         velocity.Y = KnightShape.LinearVelocity.Y;
  49.                         velocity.X =  velocityScale * m_normal.X;
  50.                        
  51.                         KnightShape.LinearVelocity = velocity;
  52.                        
  53.                 }              
  54.         }
  55. }

Thanks for your help!

127
NGUI 3 Support / Re: Permanent Button-Action
« on: January 10, 2013, 09:12:35 AM »
Hmpf, doesn't work :/

128
NGUI 3 Support / Re: Permanent Button-Action
« on: January 10, 2013, 09:03:06 AM »
Here is the structure:



The selected Button in the Inspector:



Should be the right one, shouldn't it?
The character is moving, but not the way i want him to. Same single-movement, not continuous.


Edit:

When exactly does the bool "isDown" get true/false? Is this done automatically by nGUI?

129
NGUI 3 Support / Re: Permanent Button-Action
« on: January 10, 2013, 08:51:36 AM »
Thanks for the response, but i already tried that, didn't work :/

130
NGUI 3 Support / Permanent Button-Action
« on: January 10, 2013, 07:21:25 AM »
Hey there.

So i have these UIImageButtons, where i can move my Character through the Level. The Level and the character have some physics (FarseerUnity-Plugin-Physics, static Level, dynamic Character). With the Buttons i am controlling the dynamic Body of the Character.

So, for some testing i also have within an Update()-Method same actions, but only with Keyboard-Events, like this:

  1. if(Input.GetKeyDown(KeyCode.RightArrow))
  2.                 {
  3.                        
  4.                         float velocityScale = 2.5f;
  5.                         velocity.Y = KnightShape.LinearVelocity.Y;
  6.                         velocity.X =  velocityScale * m_normal.X;
  7.                        
  8.                         KnightShape.LinearVelocity = velocity;
  9.                        
  10.                 }

So, my problem is, that via Touch the results aren't the same like on the keyboard. When i press the right arrow and hold it, the character moves all the way to the right till i release my finger from the RightArrow-Key. I tried every meaningful nGUI-Event (OnClick, OnPress etc.), but nothing worked, he just moves with the VelocityScale to the right and stops, so i have to press/click the button all the time to get the character moving.

What am i doing wrong?

131
NGUI 3 Support / Re: [nGUI]Some Problems with relative Size
« on: December 26, 2012, 11:45:33 AM »
Yes, it is :)

Thank you for the good/nice support!

132
NGUI 3 Support / Re: [nGUI]Some Problems with relative Size
« on: December 26, 2012, 07:55:21 AM »
Well my Structure is like this:



Is it better to make for each Objects an own Anchor?

133
NGUI 3 Support / Re: [nGUI]Some Problems with relative Size
« on: December 24, 2012, 06:06:42 PM »
So, made some progress. I looked in the Examples and studied the structure, and didn't understand everything :D
But, i think my mistake is, that i am trying to built the UI relative to the GameView.

So, this is my 960x640 Game View:



And as you see i marked the parts red where i wanted to have my UI-Elements. So i thought i have to place the UI-Elements incl. the UI-Root-Object like here (Scene View) and have to make the UI-Camera as big as the the other cameras (3.2) :



This gave me some headaches regarding the Scale of the Sprites. Then it came to my mind, that this is actually a seperate camera...
So i can place the UI-Root with its objects (Camera, Planes etc.) wherever i want them to. So did i, and did this:



Made a simple new UI and added these Sprites there and moved them slightly below the purple box (this is the Ui-Root Object, i guess? ) around till i got it like i wanted in the Game-View:



Now it looks fine in the Game-View and much better on the actual device.

Is this the right way to handle it? Or will be there some problems regarding future use of the UI-Elements?



134
NGUI 3 Support / Re: [nGUI]Some Problems with relative Size
« on: December 24, 2012, 02:43:42 PM »
Quote
Ok, first thing to note is that your game view is not the size you think it is. You have it set to 960x640, but your actual window is smaller than that.

Yes i know that! I have "Maximize on Play" selected, so, if I press "Play" it will give me the size/resolution i want to (and that's also how it looks on the Device)

But thank you for the clarification :)

I'll look at the video and will post if I succeded, thanks for the support ArenMook!

135
NGUI 3 Support / [nGUI]Some Problems with relative Size
« on: December 24, 2012, 09:44:29 AM »
Hey there,

i bought nGUI recently and fooled a little bit around in a new test scene. Now i want to built the GUI in my existing iPhone-project.
I have to cameras (a Main Camera and Parallax Camera for the Scrolling-Effect) with both a size of 3.2 (in order to make my other Sprites pixel-perfect).

Now i just made another Layer called GUI for the UICamera when i made a "New UI" via the nGUI-Menu. The size of the camera is 1, which looked fine to me at first, but then i started making my Interace-Objects.

First i made an TextureAtlas with all the .PSD Files.
(At this point i have to say: i really like the workflow of nGUI! I didn't have to look in the documentation and figured the most functions out by the nice structure of this plugin. That is great!)

And then i'll start adding the stuff i need, and now i got some problems with the Size and i can't handle it properly:

So here is my UIRoot-Object with the Anchor, the Panel, and an UISprite in the Scene and Game-View:



As you see, in the Game-View it's looking how i want it, but nGUI works the other way :D
It's about the Scene-View, and so i get this, when i play it:




I don't know which settings to manipulate and would be very grateful for some help, because i really really like the workflow of that plugin and want to work properly with it.

Pages: 1 ... 7 8 [9]