How to make a chasing enemy?

I’m currently trying to figure out how to make a vampire walk toward the camera(player). The problem is that I don’t know how to make it constantly face in the direction of the player while moving foreward. I also am trying to make an item non-physical. Like a hologram. Also a detection zone that can start an event upon a player entering a certain area. Any way to do these things?

Here is how to make the character forever go to you (you can remix it)

(it’s in the gallery)

2 Likes

Make the object face you and go forward and repeat.

Hello i am wondering how to make an enemy chase the player through a house with walls. whenever i try the monster goes through walls. when i turn physics on it just stands there walking into the wall. It would be really cool if i could make the monster pathfind. thankyou

Ask @techleapnz or @EdTechnocation these Guru’s have always a bound of solutions.

Hi @KGregory_14495,

A path/line is made up of lots of points, so to make a path from the camera’s position/movement we must collect and store those points in a list, so that we can tell a following character to move from point to point.

We would only want the character to follow the path if it can’t see the camera directly (search this forum for “RayCast”). This means it would have to move to the nearest point on the path, so we have to calculate this by looping through the list and finding the smallest distance between the character and each point.

This is the basic idea; there are more complications which you’ll encounter, but it gives you a starting point.

Hope that helps! Let me know if you have any further questions.

Geoff@TechLeap

Thank you for responding! I have 2 questions: does this all have to be done in the java script,or can i use the coblocks coding thing because i have never done scripting before. and can you please show me an example of this were the character/object is following the camera? Thank you so much

Hi @KGregory_14495,

Only RayCasting requires JavaScript - the rest can be done in CoBlocks.

I don’t have an example, but I have outlined the coding needed to create this functionality in my post above.

If it’s not clear for you, or if you are unsure how to code certain parts, let me know.

Karawhiua! Go for it!

Geoff@TechLeap

1 Like

thanks it really useful for me