H
H
Herman Coffman2018-10-30 22:53:25
C++ / C#
Herman Coffman, 2018-10-30 22:53:25

How to make enemy movement code (Unity + C#)?

I made an enemy movement code on curatins, I realized that this is all wrong. Tell me how to do the code (at least just in 1 direction) correctly. Worth a gamertag.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Gaydak, 2018-10-31
@Gera01

only from the comments it became clear that you need a kind of "PATROL".
from point to point route and vice versa.
since there is no more detailed description of the task, then for a start - on the crowns is quite an option.
if you need a more universal option and more complex routes, then either study, invent and write (for experience and all that, you will do it after a while, the very essence and logic there is obvious, I don’t even know what to suggest, then you need to *)
or take plugin, the same Simple Waypoint System (sws) and make on it.
*
actually about logic. array of points. from one to the other we interpolate taking into account the speed.
here you can drag a curve (using a formula or set via AnimationCurve)
change in speed - you can also optionally shove it along a curve, along an animation, linear ...
in the end - you want to rake and learn to code. and if you want - look at some simple tweener or a more sophisticated plugin.

G
Griboks, 2018-10-30
@Griboks

void Update(){
if(Input.GetKey(KeyCode.W)) transform.Translate(Vector3.up*Speed*Time.deltaTime);
}

There is such a thing called "standard controller". Check out her code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question