Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

draw sprite directly to screen?

I am looking for a way to draw many sprites directly to the screen. I don’t want to have to constantly create/destroy gameobjects or have to constantly move them around which would cause a lot of lag.

from what I see the best way to do this is with Graphics.DrawMesh, but I don’t get how to use a mesh to draw a sprite. could someone explain? or is there a better solution?

Best Answer

  • MouledouxMouledoux Member
    Accepted Answer

    3000 sprites is nothing, not for graphics at least. Your bottle neck is gonna be processing the action of 3000 sprites.

    But that's not really a problem as long as your code isn't extraordinarily lacking optimization.


    Also to put things into perspective; Tracer from overwatch, just her character model has 84,490 polygons.

    A sprite as a GameObject, has 2...


    As for creating/ destroying, you may want to look into object pooling. Where you don't delete any object, just disable them and move them out of sight till needed again. Then, instead of creating a new one, you just bring back the old one. Much cheaper than destroying and making new ones.

Answers

  • The better solution is to just make them gameobjects.

    How many are you creating/ destroying every frame to need to worry about it?

    And if you just draw it to the screen, you wouldn't be able to interact with it without needing to write your own scripts for things like collisions.

  • sorry for the long post

    it will vary but will go up over time as the game is played. I have experimented so far with using many game objects and my frames have not dropped below 80. but in a longer game/ zoomed out more, idk what it will be bit I am not super far into the development of the game.

    basically I am working on a personal project where I want to recreate a game called 5d chess (look it up for reference). the game will display every board played so the sprites add up over time (i figure worst case full screen + zoomed out there would be max 30 boards with max 20 pieces on it giving a total of 3000 sprites max)

    I store all my pieces on a string[boardx,boardy,worldx,worldy]

    boardx = the x pos on the chess board

    boardy = the y pos on the chess board

    worldx = the x pos of the board it is on

    worldy = the y pos of the board it is on

    basically it stores a grid of chess boards which you can then select the position on the board to get the piece on the space so you could look up board 2,3 space 4,5 for example.

    and then use a vector2Int to keep a list of the used worldx/worldy position. it is probably in efficient but is very convenient to update positions and access specific spots on boards

    with all the crazy moves you can do I figured it would be very hard to move existing pieces so I destroy / create every sprite when a new move is made but i hope to limit it to only the effected boards each turn.

    i am not worried about interacting with the pieces although being able to click on the did help.

    do you think it would be viable to create/ destroy/ render this many objects per frame? this probably will stay on pc btw.

Sign In or Register to comment.