How to make object follow waypoints to a center point? - c#

Im not sure how to approach this and looking for suggestions - I have a moving box (moved by the user) with paths cut into it, and a character that traverses the paths. The moving box moves as well as rotates.
At all times, I need the character to follow the paths (NOT walk thru walls) to get back to a point on the box that is
facing the screen (even when the box rotates)
Middle of the screen (even as the box moves up/down)
Here the circle scribble is the character:
What would this be called/any approaches? Is this a waypoint system or something more complex?

A nav mesh would be better if you wish to make a more complex AI for the other character say if you wanted the character to chase the player. If your route is predefined then using waypoints will be the most efficient way of creating what you want in this scenario. Here is a good tutorial by Brackeys of how to implement waypoints.
https://www.youtube.com/watch?v=aFxucZQ_5E4

Related

Character stuck on a tile unity3d

I have no idea what to say, but I have this image which shows how the character is stuck, the character gets stuck when I try to jump couple times, character is not falling.
if I jump 1 more time, the character jumps and drops to the ground
Here is movement code (didn't want to paste it here cuz it is kind of big)
oh and btw this is 2.5d game, 2d in a 3d engine
Maybe you are stuck on a subpixel?
Check the colliders: Window->Analysis->Physics Debugger.
Check the x-coordinates of the blocks in each "tower".
Change from boxcollider to spherecollider (so you slip off of small edges?)
What about the "GroundCheck Transform"? I don't see why it's a separate transform, is it a child of the player?

How to make dynamic shape adjustment to another shape

Hi guys i was wondering how to create a shape adjustment with two objects which specifically could be described as the independent cells, one of which is static, and the second one is dynamic and surrounded by "plasma". The movement of the active object must be controllable by the user (WSAD). Collision of the active object with the static one causes the static object to be swallen, though doesn't change it's position stays in place all the time. As the active object moves, passes the swallen object and troughts it out.
See the image below:
Player character
When it comes close enough to pink enemy it's starting to swallow it (surround by yellow thing)
Pink enemy is completely sourrounded when red circle is in the centre of both.
When it leaves enemy it takes off the yellow thing
I was wondering what is the simplest way to do it. I've been thinking about cloth, physics joints, mesh substraction (is it even possible?), some kind of animation... I don't have much time to do it. Can you show me the simplest way. Which tools and approach should i use? I'm not asking for full code or full solution only for some tips.
Tim Hunter mentioned a wonderful way, most perfect in 3D.
You can use another approach in 2D :
Inside OnCollisionEnter2D try finding hit points using Collision2D.contacts . See this reference .
Create some particle effect there.
Disable the enemy
Now play swallowing animation of the player.
At animation end, enable enemy again.
Maybe calculation is little tricky, still efficient.

Ascii console game: player character

I've been working on a game for a while now. It's an ASCII game in the console, using C#. It's a bit like the old top-down zelda games. I've managed to get the map to draw, the movement system works and I've added random encounters.
Since I am still a beginner, I don't know how to use classes yet, so the game is programmed entirely without them.
My player character currently is still just the cursor, but I would like it to be a bit easier to see. It could be a white "#" symbol or something. The map is in color, so after the # symbol moves, the right tile, with the right color should be placed back at where the character was. I've tried quite some times, but I simply haven't been able to figure out how I can get this to work.
So my question is: How do I draw a white "#" character where the cursor is on the map and how do I make sure it doesn't leave the map changed when the "#" symbol moves as the player moves?
If you need any more information, simply tell me and I'll post it.
Thank you in advance!
I believe what you are looking for is a good combination of Console.SetCursorPosition and Console.Clear. Try experimenting with that.

Unity eye to follow the player 2D

I'm currently working on a narrative game and don't know how to accomplish something. The game is a 2D platformer so everything is build with sprites. I have a scene with trees and the trees have eyes, I want the eyes to follow the player along, but the "pupils" need to stay within the "holes" of the tree. I have made separate sprites for both the hole in the tree as well as the pupils of the eye's. I would prefer to write it in c# :).
I have also added a concept screenshot, so you can get an impression about what i'm trying to accomplish.
http://imgur.com/pGCV8Uy
Many thanks to the person who can explain to me how to accomplish this!
Well I suppose you could use a joint to restrict the yellow pupils to stay within the holes of the eyes.
Then you could use C# to calculate the relative Vector between the character and the pupil. Guide the pupil to go in the direction of the Vector, and it will be restricted by the joint to stay in the eye. The would result in the pupil always pointing in the direction of the character while staying in the eye, which is what you want.

Collision detection 2D between rectangles

I am writting a collision detection engine for my game and I have some problems.
Indeed, since I have several fixed rectangle and one moving (the player), I need to know which side of the fixed one was collided at first by the player, to replace him correctly.
The fixed rectangle are NOT in a grid so they can be placed anywhere on the map and they can have diffents size. They are not rotated.
The player class stores it's direction vector.
Any idea?
KiTe
In a nutshell:
You'll compare the Y and X components of the bounding rectangles to eachother to check for a collision. If the top(Y) of the player is less than the bottom of an enemy then you don't need to check anymore because it's not possible that they're colliding. If the right(X) side of the player is less than the left side of the enemy then they can't be colliding. It would help to define top, right, bottom, left of each object you intend to check inside the class. This will allow you to know which side is hit also. This should be enough to get you thinking and experimenting.
Have fun!
The name is "Axis-Aligned Bounding Box" collision detection.
Now you know the name, you can Google for the rest.
thanks to both of you for your help.
I've heard about AABB, but at first sight it didnt seem to fit to my needs (since I didn't understand it well).
But after writing down everything on papper, the solution I found appeared to be exactly the same as AABB !

Categories