How do I make one of my models just follow the other actor that is being controlled by the user? I don’t think there is any more information to provide but, if you have any questions please leave it below.
EDIT: I had to rephrase my question as the original one wasn’t what I wanted, thanks for your patience!
EDIT2: fixed the problem I was having, thank you for everything it’s now working properly!
That’s a fairly broad question, I think.
You could define waypoints (essentially just positions, or empty NodePaths), and have the model move towards them one after the other. This is a situation in which a bit of vector-maths might help, as fairly-straightforward approach might involve subtracting your model’s position from the target position, and using the result both to move the model and to determine when you’ve reached a waypoint.
Otherwise, if you want something more aimless, you might give your model a “movement vector”, then move that vector around over time, causing it to ramble vaguely. (And likely try to walk into walls at times, if you don’t include a means of detecting obstacles and dealing with their presence.
There may be other methods that aren’t occurring to me offhand, too!
 Considering that you said that you want the character to walk around “randomly”, the first option above could potentially be simplified to have just one “waypoint”, which you then move around randomly whenever the character reaches it. It would call for some care that you don’t place it somewhere inaccessible, however.
Oh sorry let me rephrase my question, it came out wrong the first time. How do I make the actor follow my other actor being controlled by the user?
Ah, okay. You could perhaps use the “lookAt” method of NodePath to have the actor point towards the player-character, then move it with code similar to the code that you already have for player-movement–or you might try the AI functionality that @serega-kkz links to, above.
ok so I tried following the tutorial but am facing some errors
here is my code:
it keeps giving me this
Known pipe types:
(all display modules loaded.)
2019-12-10 22:48:31.001 Python[17381:365060] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)
Traceback (most recent call last):
File "/Users/38167/PycharmProjects/viren/scene.py", line 187, in <module>
app = MyApp()
File "/Users/38167/PycharmProjects/viren/scene.py", line 25, in __init__
File "/Users/38167/PycharmProjects/viren/scene.py", line 175, in setAI
AttributeError: 'MyApp' object has no attribute 'pandaActor'
Do you know how I can fix this problem?
EDIT: I tried doing this to the code -> https://paste.pythondiscord.com/utewitelix.py and it came up with no errors but the other model is still not following. Can you please help me?
I think you need to understand how this works, and not copy the code as you please.
So explain it to me, why it’s not working, what the code does, how to improve or edit it, etc.
I can’t do this alone, that’s why I’m asking for help/suggestions to deepen my learning and understanding of this library.
Can someone please help me as it seems @serega-kkz is not willing to help me any further?
Just to be clear, what @serega-kkz said is entirely correct. You don’t want to just copy paste code you don’t understand. You also don’t want to have other people basically write your code for you, because that usually would imply you paying those people to do that sort of work.
The goal in learning something is understanding and not have it just magically work due to a series of random interactions. People here are happy to help anyone, but only if the person that is asking for help, first tried their best to try to solve the problem on their own, which IMHO you aren’t trying to.
You’d get a lot farther if you believed in yourself. If you don’t understand something, try harder, instead of saying I can’t do this alone… Many/most of us here learned everything from scratch and got stuck with problems for a long time until we surpassed those and moved on to the next problem/thing. The information is out there and programming is hard. It takes practice and a lot of patience to master.
My suggestion would be:
- Improve your skills in Python
- Improve how to search for information online (Manuals, Forums, SO, etc.)
- Ask only when you really have exhausted all the above
first you need to read and understand the manual (the ai stuff).
then, try to write a simple minimal example to see how you can apply the stuff that you’ve learned.
then go and code it by your own and if you gget lost, you then can ask for help and tell what you’ve tried, and what was the behaviour and what you wanted it to be.
@brightening-eyes didn’t you see the original question? I already edited it saying I fixed the problem.
Thanks for your help though!
Btw you are basically restating what @tcdude said, not rlly helpful if you were trying to actually assist me. Maybe you can use this to better help people in the future.
It may be helpful in reinforcing that previous post, I think: sometimes advice carries more weight coming from two people than from one.
As to your question having been resolved, I’ll admit that I don’t think that I saw your edit until you mentioned it! It might be helpful to add a new post indicating that you’ve solved the problem for the sake of those following the thread, but not returning to the first post each time.
I’ve read it before, (some hours before I replied to the topic) and didn’t know that you’ve edited your post.
also, my intent was not anything other than to help.
sorry if that post seemed a little bit harsh to you.