Tag Info

New answers tagged

2

A possible problem is in your SetInStartPosition(). For setting the Y position it should be position.Y = screenBounds.Height - texture.Height... not screenBounds.Width - texture.Width...


1

Are you assigning cheetahX to something or drawing with it? You did not post your drawing method or where you use cheetahX further on in your code. I predict that Cheetah holds your InputHandler then you need this: public class inputHandler implements InputProcessor { private cheetah cheetah; private gameWorld myWorld; private float cheetahX; ...


1

If I remember correctly, I iterate through all sprites and use their inverse affine matrix to convert the click coordinate into local space for the sprite. I then use a trivial bounding box check to determine if the local coord can be ruled out quickly as a hit for that sprite. If the bounding box check passes, I then perform an alpha test on the pixel of ...


0

You do not have to drag drop animation controller to your script instead you can add component to game object using inspector. Add an Animator component first. On your required key press you have two possibilities as i see: Enable/disable the component as per your need. If you want to run two different states you can use states based animations. Steady ...


1

For normal cases, sprite order is determined by the Spritebatch.draw() call order. If this is the case: spritebatch.draw(apple); spritebatch.draw(mango); then apple will be drawn first and then mango will be drawn on top of that. So mango will overlap apple.


0

The solution I found was to disable 'Generate Mip Maps'. Easy fix for me, just took a bit of messing around to find.


0

Since you mentioned legacy UI is not a necessity, you can check the tutorials for new UI. Some resources: Unity official tutorial 3D Buzz youtube tutorial much better


1

Correct me if I am wrong, but from what I understand, you want to achieve the following: If so, this can be achieved using trigonometry: float easing = 0.075f; float direction = Math.atan2(target.y - sprite.y, target.x - sprite.x) / Math.PI * 180; if (direction < sprite.rotation - 180) { direction += 360; } if (direction > sprite.rotation + ...


0

This seems like a real nice fit for using something like bias and gain. Using those functions, you do a simple linear interpolation, but before using your "percent" value in the lerp, you pass it through a function to make the percent value non linear. This makes it so it still takes the same amount of time to do, but you can make it faster in the ...


0

I wrote something similar to this for the GUI library I made. It's hosted here and uses the MIT license so feel free to rip anything you want out of it. This method draws the text to a render target as I found that provided significant performance gains compared to redrawing everything line by line. Simply replace the textureBaker bit with your ...


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 ...



Top 50 recent answers are included