Tag Info

New answers tagged

3

You can attach the sprite to the child of the main game object which handles the collision detection logic. Whenever you want to flip the sprite just do it on the child object leaving the main object as it is. This way you can achieve your desired result :)


0

As far as I know, no. Prefabs are editor side only. By the way there is no need to make a prefab since you can build a generic GameObject and customize via script adding components and loading resources like sprites from file. For Example void Start(){ Sprite loadedSprite = Resources.Load("your_sprite_path", typeOf(Sprite)); GameObject go = new ...


0

pick your instantiated prefab, say GameObject go = GameObject.Instantiate(yourPrefab) as GameObject; and get for example a sprite Sprite yourSprite = Resources.Load("sprite" typeOf(Sprite)); and change the prite go.GetComponent<SpriteRenderer>().sprite = yourSprite;


1

If the sprites are in your Assets/Resources directory, you can load them programmatically as follows: Sprite[] spriteSheetSprites = Resources.LoadAll<Sprite>("spriteSheetName); This will yield a Sprite array containing all of the sprites from your spritesheet, indexed by their order on the sheet. A requirement to use this is that the image's ...


2

You need to flip the texture, not the object. Sprite/Plane meshes are one-sided so if you flip the actual object, you are seeing the back of it, which is transparent. Edit: You could also make your mesh two-sided. But Unity doesn't provide a flat, 2-sided rectangle. You will have to make it, either in a modelling program or with code.


0

I have faced this problem earlier.This is because the "Generate Mip Maps" option is on. You need to deselect that option and apply the changes to the sprites. Mip Maps are pre-calculated, optimized sequences of textures, each of which is a progressively lower resolution representation of the same image. They are intended to increase rendering speed and ...


0

your code actually draws a scaled image, have a look at Chris Campells article, it's really useful... what you have to do to simply draw the whole image without scaling... g.drawImage(getImage("Numbers/icon0.png"), 0, 0, null);


0

I think there can be a simpler approach in which you can do this , and still use Unity Mecanim for the animation. Steps:- 1) You can programatically assign texture 2D sprites from the image, and as it is a grid it wont be much difficult to do so. In the following answer the user has created his own sprite slicer and saved into the directory (optional else ...


0

Take a look at this tutorial on Sprite Sorting Layers In short, you can use the Sprite Renderer component and modify the layer properties to achieve the effect you want.


7

The sprite design of that era was heavily influenced by the technical capabilities of that time. Both the Sega Genesis and the SNES had specialized hardware for drawing sprites. But in both cases that hardware only allowed sprites with width and height which were multiples of 8. Both systems also had a limit on the number of sprites it could draw every ...


0

For anyone else in this dilemma, I would recommend these links to you: https://www.codeandweb.com/texturepacker/tutorials?km_user-type=developer https://www.codeandweb.com/texturepacker/download


1

You could re-order your std::vector<Object> by creating a function that sort it by Y position of your objects void SortObjects() { std::sort(Object.begin(), Object.end(), CompareYAxis); } bool CompareYAxis(const Object first, const Object second) { //Do the comparison here } I think this would work.


2

There's nothing particularly inelegant or "unclean" about what you're doing already (toggling every frame), especially if you're also using a fixed framerate. If you're not using a fixed framerate, you may want to consider a slight change to toggle the sprite visibility based on elapsed real-time instead, as this will ensure a more consistent flicker rate ...


2

For those unfamiliar with the concept, the proper term is sprite flickering. Old consoles like the NES could only display a certain number of sprites simultaneously, so to work around this limit and show more sprites, games would show them on alternating frames. Your solution can get quite complex if you want to properly emulate the effect, that is, ensure ...


0

If you're starting with a tileset with regular dimensions and layout (as in your example), and your goal is to create tile maps in Tiled, there is no need to use third-party tools. Tiled supports these natively and easily. There are a few tutorials on using Tiled like this one, but it's very simple: Create a new map, choose its dimensions and tile size ...


0

Go to piskelapp.com , then choose 'Create new Piskel'. Click the menu on the right, and choose import your own image; select it, then put the number of size of each tile. After you are done editing, choose Export in separate images. Done!


0

To expand @Alexandre Vaillancourt answer, I would even consider using a collection that keeps your data sorted, instead of re-sorting it every frame. struct Drawable_compare { bool operator() (const IDrawable& d1, const IDrawable& d2) const{ return d1.y < d2.y; } }; class Renderer { private: std::multiset<IDrawable*, ...


1

I would forget right away the option to create the sprites in order based on their y coordinate as it will create a hell for you because it's not a flexible design. You look like you need a common way to handle the drawing process. You can achieve this using polymorphism. I would probably create a IDrawable interface, which requires children to have ...


1

I had the reciprocal of what I should have been using. The math.h class's sin and cos function want the arguments in radians and m_ShipAngle is in Degrees. I was doing movementX = m_ShipVel * (cos(m_ShipAngle * 180 / PI)); movementY = m_ShipVel * (sin(m_ShipAngle * 180 / PI)); When I should have been doing: movementX = m_ShipVel * ...


0

You're mixing terms and techniques here, a 2D-Texture has no z-dimension. What you actually want for your normal-mapping is to fetch the texel t from the image using the usual 2D texture-coordinates and use these color-values t.rgb as a normal-vector.



Top 50 recent answers are included