3
\$\begingroup\$

I am trying to use physics in my game which is an isometric map based strategy game that the player deals with a city full of buildings, roads and people in it. I am writing the game with Swift and SpriteKit technology.

(the following picture shows a snapshot of my game)

MY GAME

My Game

I like to use Spritekit's physics library so I would be able to simulate car accidents and preventing them to go throw the buildings and other kind of stuff that physics could provide.

I am familiar with Physics and I have enough experience with Bullet and I can write a 3D game using OpenGL ES and physics, but I haven't really used physics in 2D isometric map games.

I have also wrote a 2d physic game that was really 2d (an endless runner) which was actually a sample of a book but as you can see in the following picture the gravity vector is the Y axis and every thing is pretty easy.

Here is the gravity vector that is used to create the game at the following picture.

self.physicsWorld.gravity = CGVectorMake(0, -9.8)

Someone Elses Game, Book Sample

Book Name : iOS 7 Game Development

Author : Dmitry Volevodz

You may find the book Here

2D Game

However, in an isometric map game you can't just set and assign the Y axis as a gravity vector. since the method which sets the gravity vector accepts two arguments it is a big hope that I can use physics in my isometric map games. For example something like this

I Say!!! :

As I am still using a cartesian coordinate system (perpendicular axis) X and Y axis make a 90 degree angle and if I need to project the gravity quantity over the X and Y axis it would be gCos(45),gSin(45) I haven't tested it yet.

self.physicsWorld.gravity = CGVectorMake(-9.8*0.707, -9.8*0.707)

May you please help me on setting the gravity vector and how should I define the moving objects like cars and humans and the static ones like buildings any other tips on modelling physics in isometric map are also welcome and appreciated.

The main question is: is it really possible to use physics in an isometric map based games?

\$\endgroup\$
  • \$\begingroup\$ Please do not edit my post! I don’t like it, you guys just come and find a mistyped word and do the edit! why? if you can understand the question others will do too. I am pretty sure! \$\endgroup\$ – Iman Aug 28 '15 at 23:55
  • \$\begingroup\$ You cannot use SpriteKit because it is a 2D engine, and your world is 3D in the isometric case. \$\endgroup\$ – michaelrccurtis Aug 29 '15 at 12:09
  • 2
    \$\begingroup\$ Editing questions and answers is a part of the site intent to provide good quality. Try not to take it personally because you are just fighting the wind. The site encourages people to make edits where appropriate whether it is fixing grammar, formatting or making things more clear. \$\endgroup\$ – Fuzzy Logic Aug 29 '15 at 19:44
  • \$\begingroup\$ Yeah You are right, I am getting use to it, thanks for the advice \$\endgroup\$ – Iman Aug 29 '15 at 21:26
3
\$\begingroup\$

The answer is YES,

You may set the gravity vector to (0, -some number) for this purpose, your code which multiplies the g scalar with sin and cos of 45 degree will be true if the Sprite Kit physics coordinate system could be changed to your isometric coordinate system.

I mean the direction of the gravity vector is still the Y axis, look at your Z axis (screen's Y axis), though reducing the quantity of g will make the project much more natural, so it is better to set (0,9.8*0.707).

Try to define different groups of objects with different category bit so you may manage the collisions better and faster.

I don't know exactly what are you doing but using physics in your project will be a great asset in order to manage some of the jobs.

I strongly recommend you to let physics control some of the tasks and logics and define each sprite in a pre-planned category (bits).

\$\endgroup\$
  • \$\begingroup\$ Thanks Rassam, Do you think the particles will work fine with the gravity vector defined over Y axis? \$\endgroup\$ – Iman Aug 29 '15 at 13:17
  • \$\begingroup\$ Except the explosion the other work just fine,you need to create a custom explosion for your isometric map. which is a little bit complicated but it is possible. \$\endgroup\$ – Rassam Aug 29 '15 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.