Code Monkey home page Code Monkey logo

Comments (7)

stilestr avatar stilestr commented on September 24, 2024 1

just wanted to say thanks for this post! super helpful, and very clean and understandable code. This was a great alternative to the spaghetti mess I had created, and I love the way you handled the blinking effect, even if that's not how I'm doing it in my game (changing the material instead of the scale, but it works fine if I follow your steps)

from aleksandrhovhannisyan.com.

fede7218 avatar fede7218 commented on September 24, 2024

this was really helpful to me, thank you

though Im having an issue with the model scale in the flash. Somehow the scale increase after the flash and stay that way in the others, the video explains it better

unitygame.mp4

from aleksandrhovhannisyan.com.

AleksandrHovhannisyan avatar AleksandrHovhannisyan commented on September 24, 2024

@fede7218 What is your model's initial scaling factor? I'm guessing it's not set to 1, so ScaleModelTo(Vector3.one) causes it to become larger than its initial size once invulnerability kicks in. Instead of scaling by one, it may be better to read the model's initial scale and alternate between zero and that value.

from aleksandrhovhannisyan.com.

AleksandrHovhannisyan avatar AleksandrHovhannisyan commented on September 24, 2024

@stilestr Glad it helped! And that sounds like a clever solution—I hadn't considered that, but it's probably much safer than scaling the model.

from aleksandrhovhannisyan.com.

tneilson08 avatar tneilson08 commented on September 24, 2024

This was super helpful!!

from aleksandrhovhannisyan.com.

Morkhelt avatar Morkhelt commented on September 24, 2024

This works really well in my 2D Platformer but unfortunately when I ran the code in Unity in 2D my player sprite falls through the floor when he gets hit and flashes. I'm wondering how it can be tweaked so that the sprite doesn't fall through the ground when he takes a hit but can still phase through enemy sprites

2023-08-14.21-19-49.mp4

from aleksandrhovhannisyan.com.

AleksandrHovhannisyan avatar AleksandrHovhannisyan commented on September 24, 2024

@Morkhelt Hard to say, but my article cautions that you should scale the sprite and not the entire character model; scaling the latter can break collision detection, which I suspect is what is happening here.

from aleksandrhovhannisyan.com.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.