Jump to content

Kubinna

Members
  • Content count

    1
  • Joined

  • Last visited

  1. Kubinna

    Platform builder

    Hello, I am creating 2D mobile game, where will player create own platforms on which will be moved fluid. From testing I found, that in 3D I have better fluid physic and performace, so I decided create this game in 3D, but use camera in 2D view and I want use your asset to build platforms. Platforms will be: Straight -> blocks Combined with other platforms -> no spaces between neighboring platforms Every platform could be erased Player will create platform from first click to mouse position or position where was released mouse button Creating of platforms by player (own script): As first thing I am calculating angle between two points (first mouse button click and release button position or mouse position in drag) Via this angle I will calculate edge points by given height of block (for me in 2D it is width -> variable widthLine) Using function CreateShapeFromPolygon Platform is created angleDeg = Mathf.Atan2(platform.secondPoint.x - platform.firstPoint.x, platform.secondPoint.y - platform.firstPoint.y); points = new Vector3[4]; points[0] = new Vector3(platform.firstPoint.x + widthLine * Mathf.Cos(angleDeg), platform.firstPoint.y - widthLine * Mathf.Sin(angleDeg), 0f); points[1] = new Vector3(platform.secondPoint.x + widthLine * Mathf.Cos(angleDeg), platform.secondPoint.y - widthLine * Mathf.Sin(angleDeg), 0f); points[2] = new Vector3(platform.secondPoint.x - widthLine * Mathf.Cos(angleDeg), platform.secondPoint.y + widthLine * Mathf.Sin(angleDeg), 0f); points[3] = new Vector3(platform.firstPoint.x - widthLine * Mathf.Cos(angleDeg), platform.firstPoint.y + widthLine * Mathf.Sin(angleDeg), 0f); platformObject.GetComponent<pb_Object>().CreateShapeFromPolygon(points, m_Height, m_FlipNormals); Combining of platforms: If player click on created platform from side where he clicked will be created another platform Not combine objects like this (on center -> use last point of created object): Combine objects without any spaces like this:(because player can drag with second platform, it must be dynamic generated by mouse position) Problems: Is there some chance how create this platforms easily than how I am creating them now? (point -> Creating of platforms by player (own script)) Is there is some posibillity how combine objects without any spaces? I tried calculate it by angles and distances, but it is not precisely and very hard. Not solved yet by math. Is function CreateShapeFromPolygon good for use on this problem or is some better function? In combine of objects, objects can´t overlap, because in overlap area will be maybe another shade? If platforms will don´t have overlap areas, and one object will be erased, combined object must be edited to basic shape. Thank you very much for your time and help!
×