• 13
• 15
• 27
• 9
• 9
• ### Similar Content

• While looking out for that pesky Terrator, our little alien is doing a bit of relaxed mining down on the new gas planet "Lelantos" this weekend....

• I have a native iOS game (objective c, XCode build) which I am considering to port to other platforms.
Core gameplay is based on solely on geographical maps, and custom drawing over maps. It also has Core Data. This part is complete in development.
What is not done yet is: monetization, gamification (leaderboards, challenges) and multiplayer functionality.
As I think more about it, I am tempted to think if this is the right time to move to a cross platform tool such as Unity. But before dedicating time to port my 5 years side-project effort in Objective C, I really want to know if its worth it.
- Does Unity support such plugins / assets that will fulfill all my above requirements?
- Unity Personal seems to have only 20 concurrent users - is it too costly scaling if I decide for extending to web and android platforms?
- What is the general workflow involved in publishing to iOS, Android, PC, and web platforms while using Unity? I mean to ask about various points of signing stuff, paying fees and getting certified.
- How long will it really take to port my entire Objective C project into Unity? I am somewhat familiar with C# but I am finding it hard fidgeting with Unity IDE as lot of things are focused around FPS and 3D while my game is still 2d - not much action involved. I seem bit overwhelmed by the list of features I see there. All in all, I do not want to lose my momentum while still making sure its portable to everywhere.
- Any assets I could use (for free to try basis in debug) that are relevant for my game?
- Last but not the least, are there any costs that I need to be paying upfront to Unity, for using it (apart from their monthly subscription model)? I don't understand their costing for multiplayer in conjunction with their subscription fees - if someone could kindly elaborate.
• By GytisDev
Hello,
me and few friends are developing simple city building game with unity for a school project, think something like Banished but much simpler. I was tasked to create the path-finding for the game so I mostly followed this tutorial series up to episode 5. Then we created simple working system for cutting trees. The problem is that the path-finding is working like 90% of the time, then it get stuck randomly then there's clearly a way to the objective (tree). I tried looking for some pattern when it happens but can't find anything. So basically I need any tips for how I should approach this problem.
Use this image to visualize the problem.
• By aymen
please any know how can i' calculate the centroid from any number vertices

• Good day sir/maam. I am developing a game for my thesis and im done with multiplayer and plan to start the implementation of AI but i dont know how/where to start. Please give an advice. I am developing it in C# using UNITY.
Im am now collected all pieces that has possible moves but i am stuck on which best move to select. I hope you will help me. This is link explained the game https://en.wikipedia.org/wiki/Game_of_the_Generals

# Unity 2D Jumping

This topic is 2634 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Currently I am working on a 2d fighting game and the jumping system I have currently creates a funky looking jump that I don't like. Here's a graph of what the jump looks like in 2d space in relation to the sprites X,Y Position while jumping.

I looked through a few of the topics here and tried to incorporate their methods, namely the one from this topic http://www.gamedev.net/community/forums/topic.asp?topic_id=559493 but it keeps my sprite at the top of the screen without it coming back down for some reason.

Here is the current code I am using

private void Jump()        {            if (canJump)            {                if (isJumping && !moving)                {                    //velocity.Y = (float)gameTime.ElapsedGameTime.Milliseconds * acceleration.Y * (float)0.5;                    isOnGround = false;                    position.Y = position.Y - jumpSpeed;                    position.X = position.X + velocity.X;                                       if (position.Y &lt;= (groundLevel - jumpHeight))                    {                        moving = true;                    }                }                if (moving)                {                    position.Y = position.Y + (jumpSpeed/2);//velocity.Y;                    position.X = position.X + velocity.X;                    //currentState = CharState.JUMP;                }                if (position.Y &gt; groundLevel && !isOnGround)                {                    //velocity.Y = 0;                    velocity.X = 0;                    isJumping = false;                    position.Y = groundLevel;                    isOnGround = true;                    moving = false;                    canJump = false;                    currentState = CharState.IDLE;                    currentFrame.X = 0;                }            }            else            {                if (currentFrame.X &gt; 2)                {                    canJump = true;                }               }           }

Any help would be awesome thanks!

##### Share on other sites
What do you mean by "funky looking jump"?

##### Share on other sites
It doesn't have a nice curve like I would like while they do a forwardor back jump.

##### Share on other sites
You may want to adapt a parabola curve, similar to ballistics subject to gravity.

##### Share on other sites

Your players should receive a constant gravity (an acceleration that increases their velocity downwards unless it's touching the ground) each frame, and the action of jumping should apply an upwards velocity to the player.

That way, upon pressing jump, the player's y velocity shoots up, and the gravity makes that upwards movement decay until the player starts freefalling back down to the ground.

##### Share on other sites
So I'm still having trouble, the sprite will either not get off the ground or it will go shooting straight up into the air and not come back down.

Here's the two equations I'm using.
float gravity = -0.9;Vector2 acceleration = new Vector2(0, 5);velocity.Y += (float)gameTime.ElapsedGameTime.Milliseconds * gravity;or I use velocity.Y = (float)gameTime.ElapsedGameTime.Milliseconds * acceleration.Y + gravity; position.Y = position.Y - velocity.Y; position.X = position.X + velocity.X;

then in my Sprites class in it's update loop I have it do this
//pseudoupdate(GameTime gameTime){     if(upButton.GetState() == ButtonState.IsPressed)     {          velocity.Y +=10;     }}

I dont know exactly what I am doing wrong

##### Share on other sites
You have several problems. You're mixing accelerations, velocities and positions.
Quote:
 velocity.Y += (float)gameTime.ElapsedGameTime.Milliseconds * gravity;or I use velocity.Y = (float)gameTime.ElapsedGameTime.Milliseconds * acceleration.Y + gravity;position.Y = position.Y - velocity.Y;position.X = position.X + velocity.X;

What do you use?

If you want to use the second velocity equation, you need to apply the delta-time to gravity also. And the result is a change in velocity so you need to add that to the original velocity. I.e.,

velocity.Y += (float)gameTime.ElapsedGameTime.Milliseconds * (acceleration.Y + gravity); // not the parentheses.

Also, you need to apply the delta-time to the velocity in your position equations:

position.Y = position.Y - velocity.Y * delta-time; // EDIT Question: why do you subtract?
position.X = position.X + velocity.X * delta-time;

[Edited by - Buckeye on December 29, 2010 9:51:55 PM]

##### Share on other sites
float gravity = -0.9; // You may have to adjust this value depending on what// units you are using. Play around with it.// Vector2 acceleration = new Vector2(0, 5); // get rid of this// You should determine how much time has elapsed first and save it, to// keep the code concise. In fact, you should pass this value as a parameter// to the function where you do physics updates.float elapsedTime = gameTime.ElapsedGameTime.Milliseconds;velocity.Y += elapsedTime * gravity; // use this one// DO NOT use velocity.Y = elapsedTime * acceleration.Y + gravity;// That means that the guy is wearing a rocket pack, and furthermore that// gravity has no concept of time elapsed.// position.Y = position.Y - velocity.Y; // This is the problem: you must also// account for time elapsed when you update the position with velocity.// Also, velocity is a signed quantity, so you should always be adding it,// not subtracting it. Establish a consistent sign convention. E.g. if you want// the positive Y axis to be up (as in math), then gravity is negative, // and if you want the positive Y axis to be down (as in screen coordinates),// then gravity is positive. But either way, you always ADD acceleration to// velocity, and always ADD velocity to position.position.Y += elapsedTime * velocity.Y;// Same thing in the X direction. position.X = position.X + velocity.X;//pseudoupdate()// The function that handles key presses should probably not // care about elapsed time.{     if(upButton.GetState() == ButtonState.IsPressed     && onGround() // important! Only set the Y-velocity once.     // You should also check that the button has been released since the     // last time the player landed - you don't want him to bounce up and down     // repeatedly if he holds the button for a long time.     {          velocity.Y = 10; // set, don't add.     }}

##### Share on other sites
Ok I have it working now with a beautiful curve! Thank you everyone who helped me out!

Here's the end code I have

 float gravity = -0.09f;        private void Jump(GameTime gameTime)        {            float elapsedTime = (float)gameTime.ElapsedGameTime.Milliseconds * speed;                        if (canJump)            {                if (isJumping && !moving)                {                    isOnGround = false;                    velocity.Y += elapsedTime * gravity;                    position.Y -= elapsedTime * velocity.Y; // I found that if I had//this negative and the gravity negative it worked but didn't work with the recommended way// for screen coordinates. I don't understand why it didn't work like that but hey it works.                    position.X += velocity.X;                }               }        }

Thank you again everyone! feel free to use this code :D