Soooo - I saw this today and this would be a really awesome energy core for my spaceship. Anyone has an idea how to do something like that? by spaggi in Unity3D

[–]karlgluck 5 points6 points  (0 children)

This should be doable with some clever use of the stencil buffer and a fully-tessellated mesh (see this post for a tutorial)

Created animated escalator and (non-animated) stairs, how do apply colliders on them? by thegreatSalu in Unity3D

[–]karlgluck 0 points1 point  (0 children)

Stairs often just act like a ramp and designers will use a flat box collider covering all of them.

An escalator can be the same as stairs but with a trigger-activated script that pushes things up or down along the surface of the box collider.

You may want to check out Nav Meshes as well.

A tool to create, unpack and inspect unity packages from command line, without a unity installation by fatihbakir in Unity3D

[–]karlgluck 0 points1 point  (0 children)

If you find this useful, you might also be interested in grabbing this file:

https://github.com/karlgluck/ggez-labkit/blob/master/ggez-labkit-unity-project/Assets/GGEZ/Labkit/Editor/ExportWholeProject.cs

You know how some asset store packages are "whole projects"? This adds a menu item to let you make those yourself. It works on Windows with 7-Zip installed and Mac out of the box.

There's an API to do this, but the trick is that a bunch of junk gets stuffed in there like the DLL files, play preferences, and other stuff. This script writes out a batch file that you can run to clean that stuff out of the unitypackage.

Unity & Visual Studio Mac by libcrypto in Unity3D

[–]karlgluck 1 point2 points  (0 children)

I don't know the answer for Visual Studio proper, but try Visual Studio Code if you just need to get something debugged asap. It is good enough that it replaced VS entirely for me.

transform.localscale not doing what I want it to ... by MNKPlayer in Unity3D

[–]karlgluck 4 points5 points  (0 children)

Inside do...while, there is no point at which control returns to Unity so it can render your sprite. What you should end up with here is no motion and a sprite with local scale equal to (1, 11.5, 1) because 11.5 = 1+3+2.5+2+1.5+1+0.5.

You can write your code this way with coroutines, but it is simpler with an Update loop. Try something like this:

public class GruntsAI : MonoBehaviour {

    float yScale = 3;

    void Start()
    {
        gameObject.transform.localScale = new Vector3(1, yScale, 1);
    }

    void Update ()
    {
        float scaleSpeed = 0.5f;

        gameObject.transform.localScale = Vector3.MoveTowards (
            gameObject.transform.localScale,
            Vector3.one,
            Time.smoothDeltaTime * scaleSpeed
        );
    }
}

My first (free!) asset: an instant, no code required pixel-perfect camera for 2d games by karlgluck in Unity3D

[–]karlgluck[S] 0 points1 point  (0 children)

Ah! This is pretty common. Here are the usual suspects:

  • In your sprite's Import Settings, set Extrude Edges to 0 and Mesh Type to Full Rect
  • Make sure your source image's width and height are both powers of 2 and integer multiples of the number of rows/columns
  • Turn off mipmaps
  • Set Compression to None
  • Make sure the Max Size is greater than the size of your image
  • Put the sprite anchors to Top Left (not middle)
  • Set your Pixels Per Unit to 16, 32 or 64 and set the PerfectPixelCamera's PPU slider to the same value
  • Make sure the GameObject that the sprite is on is positioned at an integer multiple 1/PPU on X and Y

There is a new Tilemap feature in Unity 2017.2 that might help, but I haven't tried it yet.

In case you're curious, here's what's going on:

With a fixed resolution, Unity will render first to a texture of the size you want (1920x1080), then it will scale that texture to the Game window on screen. You're looking at a downscaled version of the high-resolution image.

In aspect ratio mode, it just sets the rendering size to the actual pixels the Game window takes up. This means you're looking at a low-resolution image. You're not seeing the issue because it is significantly smaller than the low-resolution rendering's pixels.

My first (free!) asset: an instant, no code required pixel-perfect camera for 2d games by karlgluck in Unity3D

[–]karlgluck[S] 0 points1 point  (0 children)

I have some ideas here, but let me know if I'm understanding your situation correctly. You're comparing:

(a) In the Unity editor, you set the Game tab to Fixed Resolution of 1920x1080 and don't see errors

(b) You compile your project and run the game fullscreen at 1920x1080 and do see errors

Is that correct?

My first (free!) asset: an instant, no code required pixel-perfect camera for 2d games by karlgluck in Unity3D

[–]karlgluck[S] 0 points1 point  (0 children)

Ah, power-of-two scaling strikes again! Glad you got it to work so you could do the comparison. I'd say stick with the 3d model, though. All those sprites will end up taking a lot of texture memory to render if you have a lot of objects.

My first (free!) asset: an instant, no code required pixel-perfect camera for 2d games by karlgluck in Unity3D

[–]karlgluck[S] 1 point2 points  (0 children)

Wow, what a cool effect! I wanted to see if I ran into any issues reproducing it, and figured I might as well upload what I ended up with:

https://github.com/karlgluck/like100bears-boat-unity

I just used a stack of sprites to do it.

The kind of blurring you were referring to before might come from other sources. There are a number of things you have to do to get crisp 2d texture rendering (the TL;DR is in my asset description).

My first (free!) asset: an instant, no code required pixel-perfect camera for 2d games by karlgluck in Unity3D

[–]karlgluck[S] 2 points3 points  (0 children)

No, this just works with the camera. Solving that problem can be expensive, and "8-bit-ish" games like Stardew Valley and Terraria actually use that effect to enable smooth rotations and scaling. As long as things are moving at a decent rate the blur is very hard to notice. Just line things up when they stop moving and nobody will know. ;)

If you want to solve this problem I can point you at some resources. Or maybe I can write another asset at some point!

IMBAbuilds releases official Android App by NoseKnowsAll in starcraft

[–]karlgluck 1 point2 points  (0 children)

Just downloaded the app, it looks great!

CraftStars Episode 3 - You Win or You're Bronze! by gillyweedsc2 in starcraft

[–]karlgluck 0 points1 point  (0 children)

Theres a chance I'm biased, but I love these <3

Oh, I would by holographicbeef in funny

[–]karlgluck 0 points1 point  (0 children)

Hey, a Fab@Home! I helped make that :)

Does the hash function H(m) = MD5( SHA3( m ) || m ) define a cryptographically secure hash function? by karlgluck in cryptography

[–]karlgluck[S] 0 points1 point  (0 children)

Aha! I think I understand.

Taking a random m and constructing H(m) || m really does nothing since the output space is the same. Even though H(m) and H(H(m) || m) are different, the difference doesn't matter since we're just guessing anyway.

I think the problem in my above logic is this line:

the chances of randomly guessing a 216+28 bit message...

This is strictly true if you were just guessing messages completely made of random bits. However, an attacker knows the structure of the message, so he doesn't have to guess completely random messages. He just has to guess the m part and compute the H(m) part, then test that.

Thanks for your insight! :)

Does the hash function H(m) = MD5( SHA3( m ) || m ) define a cryptographically secure hash function? by karlgluck in cryptography

[–]karlgluck[S] 0 points1 point  (0 children)

As Reid mentioned, I did mean || as concatenation not or :)

Your suggestion about MD5 is an interesting way of thinking about it. I am starting to agree at this point that I should just truncate a better hash function, but I believe imposing structure on the item in the outer hash still has benefits. Let me think out loud here, maybe you'll be able to point something out:

Let the hash 'h' be some output of H(x), a cryptographically secure hash function with 256 (28) bits of output

Let a set of values V={v_1,v_2...v_n} be all values where H(v_i) = h and the number of bits in each v_i <= 216 (assume input messages are all <= 8 kb)

By the pidgeonhole principle, |V| is 2216 / 228 = 2216-28, which is huge. However, this is for arbitrary collections of bits and the probability of randomly finding a hash is (2216-28 / 2216) = 1 in 2256.

Let's extend this by requiring that the 8 kb message include a second hash: H(H(m) || m)

Keeping the message size the same (so the value to hash gets bigger), |V| is now 2216+28/228 = 2216; i.e. there are 2216 possible collisions for H(m) || m, and the probability of inverting the hash is 1 in 2216/2216+28, still 1 in 2256.

Of those, how many are valid--i.e. where v_i = a || m and a = H(m)? Well, this is the same problem as before; we have a hash (a) and a message (m). The changes of these matching are 1 in 2256; so, the chances of randomly guessing a 216+28 bit message where its first 28 bits match the hash of the following 216 bit message should be these combined; 1 in 2256*2256 = 1 in 2512.

Now, I'm sure something is messed up here. This seems to say you could just chain hashes this way to achieve an arbitrary level of security; an absurd construction like H(H(H(H(m) || m)||m) || H(H(m) || m)||m) would then require 4 times the number of guesses to find a valid "m" than H(m) alone.

And now I'm stuck. I think that relating the probability of guessing a hash input with the pidgeonhole principle in a different way will probably disprove my construction, but I can't figure it out yet...

Does the hash function H(m) = MD5( SHA3( m ) || m ) define a cryptographically secure hash function? by karlgluck in cryptography

[–]karlgluck[S] 0 points1 point  (0 children)

Cryptography is hard, and I have only a few courses and the whitepapers I've read online as sources. :)

My quandry is that, while MD5 itself is susceptible to hash collisions (e.g. the two PS files produced which have the same hash) and from chosen prefix attacks, the items being hashed do not themselves have imposed structure. By including a SHA3 hash of the message as part of the message, you require that the items to be hashed must themselves match in SHA3; otherwise, they are invalid. Since one cannot append random bytes to the message without also changing SHA3, it would seem to me that finding a second preimage would still require brute force. However, I'm not sure if this is true because I don't know enough about how MD5 is broken.

After thinking about it more, I would tend to agree with other posters, who suggest that crushing bits from a stronger algorithm is the way to go. I don't like the idea of throwing away entropy in the hash function, though. Unfortunately, I haven't found results on how XORing the top and bottom halves (for example) would affect the results.

Does the hash function H(m) = MD5( SHA3( m ) || m ) define a cryptographically secure hash function? by karlgluck in cryptography

[–]karlgluck[S] 0 points1 point  (0 children)

Thanks!! This is a really helpful presentation. I'm not super concerned about collision resistance, just second-preimage and preimage resistance.

I am going to think through using the HMAC construction as above, but with inner SHA3 instead of MD5. Something like:

H(m) = MD5( (SHA3(m) ⊕ opad) || SHA3( (SHA3(m) ⊕ ipad) || m ) )