Code Monkey home page Code Monkey logo

Comments (3)

raganvald avatar raganvald commented on May 28, 2024

I added this to fix a bug. If the the enemy went to fire but the player moved out of target range, the value can get set to null before the enemy fires and causes a null exception. When this code executes it tries to access target.position with a null target and causes a null exception. This is a result of when firing the animation gets played than the animation tells when to actually fire based on its callback.

There are a few ways to fix this, but this seemed the simplest. I probably should have broke this fix out to a separate git commit so it could have explanation. Since the error was introduced as part of the functionality of syncing the animations with firing, i just included it with that commit.

from simpleincremental.

ErikOverflow avatar ErikOverflow commented on May 28, 2024

That makes sense. If we separate projectile firing from the animation it should eliminate this issue. We might want to revisit how projectiles fire. I'm still flip flopping on triggering projectile launch from the animation. I think a solution of "queueing" the projectile launch with its parameters at the start of the attack and "releasing" it via animation (so it's not doing a target check during the release portion) might work.

Also, rather than have a reloadTime that affects the coroutine to delay the projectile throwing, maybe we refactor it to attackSpeed and have speed affects the animator's Attack animation speed? Then we can have an "Attacking" bool parameter (instead of a trigger), and have the attack animation continue looping on itself while "Attacking" is true.

Does that make sense?

from simpleincremental.

raganvald avatar raganvald commented on May 28, 2024

You can do the same thing by changing the speed of the animation in code. My biggest concern with the separate coroutine is trying to sync them. The only way to tell would be to try and see what works better or has better drawbacks. Im guessing your trading independence from animation for syncing difficulties.

from simpleincremental.

Related Issues (18)

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.