Tag Info

New answers tagged

1

I have to agree with Ben. You can do things in Update but once you start having to manage many different objects changing simultaneously it is much nicer to do it with CoRoutines. Having said that, it took me several iterations and seeing good examples in the Unity demos to feel like I understood them properly. For now, go with what makes the most sense. ...


0

Coroutines are very useful for actions like these. When programming a game you've probably found yourself wishing each object was independent with the ability to do things over time without blocking other objects from executing. To achieve this normally, we'd need a new thread for each object that exists in the game world ( which is is impractical for ...


0

manage all in the Update (I use c# and pseudo code) bool Charging=false; float timer = 2f; GameObject bomb; void Update() { ... if (Input.GetButtonDown("Fire2") && Charging==false ){ bomb = (GameObject) Instantiate(bombGO, transform.position + offset,transform.rotation); Charging=true; } ... if ...


1

Please take note that the question was unclear and changed meaning 3 times, hence the 3 answers in one How can I verify that a given size is a multiple of another? This is a very good case to use the Modulo operator. Let's say you have a texture tex with size (width, height). Now you want to render the texture with size (drawWidth, drawHeight) on the ...


0

Only change the rotation whenever your distance is above a certain delta. Also center your sprite, right now you're using the top-left corner of the sprite.


1

Yes, you are stuck with needing a child object for each individual sprite that makes up your characters. It's not as tricky as it sounds though. You can create one generic "Humanoid Character" prefab with child objects like "Body", "Helmet", "Weapon", etc. You can then use this prefab for both PC and NPCs. Layers Pay attention to Sprites layering. Almost ...


-1

If you create a single material for the sprites, and they use a spritesheet, they should be batched into a single draw call automatically. :) From the Unity3D answer hub (kindly answered by ivomarel): Yes, make sure that the sprites are in the same atlas. When you select a sprite, (Texture type should be sprite), look at the inspector and choose ...


0

Your getters (getCTwoInst, getCOneInst and getOne) return copies so you're calling the animate function on a copy of a copy of your sprite. This modified copy is then left unused. Return references instead: Two& getCTwoInst() {return cTwoInst;}


0

What you need, at least I guess, is an implementation of mipmaps for your 2D trees. A mipmap are a large frame in which the same object is present in different resolutions. For example, you can have a texture with a 1024x1024 tree image, next to it another one at 512x512, then a 256x256 one and so on... Then your tree object checks for the zoom level the ...


0

You've made an infinite loop: def nextStageCollision(self): for tile in self.nextStageCollision(): You probably meant something like: def nextStageCollision(self): for tile in self.tileList: Note what you are iterating over. You are calling the nextStageCollision to find what to iterate over, which calls nextStageCollision to find what to ...


0

Java can be quite a pain when trying to load files that are inside the .jar. So first, try to put your sprites folder outside of your jar, on the same level. See if that works. To load files that are inside the jar, you must use this following piece of code to retreive it's URL: getClass().getResource("myimage.png") So your line of code would be : ...


1

I would read this and this for some helpful tips. The short answer is no, but Unity has some very convenient and efficient tools to handle scaling images. So ideally you should choose the highest resolution you wish to support, and let the engine scale it from there. I'm not 100% on this, but I think I read somewhere that when you build the project for ...



Top 50 recent answers are included