Im coding a platformer game and started cloning hollow knight to get inspiration and training. I'm investigating the behavior of the system during combat and I have some doubts and I'd like to get some help.
As for the hero:
Is there a cooldown between slashes or can you slash as fast as you want?
Is the hitbox of the slash bigger than the slash graphics?
When hit, you get this animation and you are invulnerable for a while. Can it happen that you land on an enemy after the animation and get automatically hit again??
when you hit something you get a small kick back too. Can you hit/be hit during this kick back ?
As for the enemies:
When hit.. do they "jump back"? I mean some kind of kick back animation that moves the enemy away from the hero. I think some do and some don't ..
When being kick back after an initial hit.. can they be hit again or they also get their invulnerable time?
and during this kick back moment can you be hit by them (by just touching them) or do their hit boxes get totally disabled?
can flaying monsters ignore platforms or they find you using something like A* ?
After some experimenting with the game itself and playing some videos in youtube frame by frame I thin that:
There is cooldown, you cannot slash as much as you click.
I would say that the hitbox of the sword is pretty accurate with its sprite
When you hit something you receive a kick back, which is a surprise
but yup, both you and the enemy get opposed kick backs that separate
both of you. You get additional invulnerable time that allow you to
move away from possible involuntary collisions.
As for the enemies:
The do get a kickback but the bigger foes do not.
Is hard to say because the kick back you get in your hero makes it hard to beat the enemy again. I've read that there is a badge that disables your kick back. So I understand they DONT have invulnerable time. Otherwise the badge would be useless.
since you get kick back you cannot be hit by them. Don't know what happen if you wear the badge.
Flaying monsters do collide with the platforms although I doubt they need something as sophisticated as A* but is unclear.
Related
I have recently begun working on a game for a uni project and will visit this site probably a lot while encountering problems. This time it's a small but annoying problem.
I am doing a 2D sidecroller so I used the template for it to get me started. I already put in the input for attacking and want that the character stops moving when he does the attack animation. On the ground it works wonderfully, but while airborne the character doesn't completely stop in the air, but is slowly decending during the animation. And I want that the character stops completely.
Here is the Jump Handling from the 2d sidescroller template.
Here is the event tick and where the animation update is called (Ignore the attack counter stuff, doesn't influence)
Here is the Animation update code and the "Stop Movement Immediately" node. It has to be said that I am doing what I learned from a tutorial.
As the name implies, the node should stop movement, which is does in the X Axis, but not completely in the Z Axis. I tried it by saving the location of the Player Character when he attacks while in the air but either I couldn't get the code right or it doesn't work like that.
I would be thankful for advice with this (rather petty) detail.
If your problem is strictly while falling, try setting the gravity to 0 while attacking, create an Event in the animation that fires up when it's finished and then capture it to set the gravity back to the original value.
I'm working on a VR project in Unreal and I'd like my player hands to form to certain objects whenever the user grabs them. (I.e. the way our hands work) Unfortunately, I haven't really found any examples online of others doing this.
For example, I'd like when the user picks up say a hand held tool like a hammer that the hand would wrap around the handle. When the user grabs a basketball the hand shouldn't be closed but, expanded like a you would if you were to palm a basketball in real life.
I haven't done a lot of testing with this but, I'm pretty sure since the hands are based off of a Animation Blueprint that they simply ignore collisions and follow the animation.
I guess the simplest solution would probably be based off of collision where the hand plays an animation and as the fingers of the hand wrap around the object they stop at that position where they collide with the object in question. If it is even possible that is.
I am currently working on a mobile game and I can't help but notice that whenever an object (an obstacle in my case) is instantiated or destroyed, I get a sudden FPS drop which is critical for my gameplay.
To help give an idea, I instantiate obstacles on top of my screen every 1.5 seconds, then I scroll them down. If the obstacles reaches the bottom of the screen already, I destroy them to prevent memory leaks/waste.
I'm still pretty new to Unity development. Am I on the right track though? What is a better solution to prevent this sudden frame rate drop?
Do you have any big / nested loops or complex processes going off as part of instantiation (Look at your awake/start methods)?
Regardless, look into object pooling as a better method to handle this type of thing.
For a basic example, instead of creating/destroying projectiles of a gun every time it's used, give that gun a "projectile pool" that creates n projectiles when the level loads. Then, when shooting, just set the projectile's position back to the gun and set the projectile as active. After impact, have the projectile deactivate (or after a few seconds if nothing is hit).
I have my "player" gameObject standing atop a platform. He press a combination of keys, I verify that he's standing on the right kind of platform, and I run this code:
Physics2D.IgnoreLayerCollision(playerLayer, plataformLayer);
The intention being that he'd drop down from the platform. Instead, nothing happen immediately. The player is still atop the platform and can move around - only if he gets out of it and tries to get back to it, only at that point will he fall down from it.
So I made a temporary ugly workaround:
Physics2D.IgnoreLayerCollision(playerLayer, plataformLayer);
rigidbody2D.AddForce(transform.up * jump / 1.5f);
This will force the player to jump, making Unity "recalculate" the collisions and the player will, as I want to, pass through the platform. The even weirder part is: if the jump isn't high enough (100 force at 1 mass with 0.5 gravity scale seems to be the minimum), the player will still land on the platform, even though Unity is supposed to be ignoring those collisions.
I also tried pushing the player downwards, both with force and direct velocity, but no luck - he still collides with the platform, he only stops colliding with it after being away from it once.
Also, my player Rigidbody2D Detection Mode is set to Continuous, and I tried setting the platform up in many different ways, with and without a Rigidbody2D.
Any ideas on how to make the player instantly fall down from the platform as soon as collisions start being ignored? Thanks in advance.
I had been having the exact same issue. I have an alternative solution that you may find to your liking.
Rather than disabling or moving the terrain to be ignored, temporarily set the rigidbody2D of your player gameObject to kinematic. This will not cause you to 'drop' through the platform as you would like - but it will allow you to create the illusion that you are, by briefly using transform.Translate (or Vector3.Lerp, if you like) to move your character down via code.
This will disable Rigidbody2D.AddForce, but will still allow for set movement via rigibdody2D.velocity, if that is preferable to manipulating the transform directly.
Ensure the downward velocity lasts only as long as you are Kinematic, and try to let it match the gravity of your game, and it looks pretty seamless.
If you turn the rigidbody back on too quickly, it can (even with ignoreLayers :/ ) still jump back up to the platform - but if you leave it on too long, you can drop through more than one intended one-way platform, or even :O through the bottom of the stage!
This is easily avoided if you can be careful - personally I used both MonoBehaviour.Invoke to set a very short time limit on how long the player would remain Kinematic (about 0.5 seconds), AND I disabled Kinematic as soon as they moved 0.5 units from the point where the 'hopDown' was initiated.
If your gravity / platforms / character scale are vastly different than my own, you may have to experiment with some different numbers.
This has been my first attempt at an answer on stackoverflow, so I hope it has been helpful!
One easy way to do this is after calling
Physics2D.IgnoreLayerCollision(playerLayer, plataformLayer);
You reset the player's layer:
player.gameObject.layer = playerLayer;
It's sounds like you have covered a ton of possible solutions to this problem before coming here so, good job there. I listed a few alternative ideas below. I hope they help. Good luck!
Remove the collision object from the platform itself.
Offset the collision object to be in some remote location so it will not interact with the player. Offsetting the object may cause the collision to have a similar reaction to the jump you mentioned.
I'm trying to get a decent collision system for my Unity game.
I use OnTriggerEnter and 'Exit to set and unset a 'collided' flag.
I remember the last position of my character before each move.
I then make a move and use the OnTriggerEnter flag to reset the character back to the last position it was at before moving if there was a collision.
The problem is I'm getting stuck to walls quite often and the above method seems overly complex and I'm wondering if I'm missing a more straightforward approach.
Does the above seem like a reasonable strategy for collision detection in an isometric game?
Thanks
s
sure, thats what we did back in the day before unity came in to play,
personally i always used a future ghost, a invisible player that took the step and then told the player if it was okay or not. i didnt like to throw the player around to much.
and you always have to check that the player will not enter the red zone.
Lets say that we jumped inside a red zone and figured out that this is not the place i am suppose to be, so we take a step back, but a step back does not mean we went out of the red zone, we just approced the border a bit.
by using a ghost we ensure that the player never enters the red zone. but a ghost would send back a message to the player saying "no no" to this way.
an example would be we take 1 step inside the red zone, our velocity will bring us 1.1 inside the red zone before the logic to step 1 back kicks in, which means that we will be 0.1 inside the red zone, but our script didnt pick that up because it didnt take the velocity drifting over time in to account.
This was in my experience the most difficult and fun part, going from a cubic move to a more action pack time sensitive one, where you have to take velocity in to consideration, thats why they call it physics engines and not bounding box checking engines. haha.