hello,
I have an enemy that uses a floating movement component and AI move to to walk along a spline.I need to read it’s velocity from other class.but it doesn’t work.here’s a video indicating what happens:
as you can see I gets correct value if I get velocity from the enemy self class (200),and if I get the enemy’s velocity from controller,I get a random number.
The enemy class was a character before,but I just changed it’s parent to pawn so that I can use floating component.would that be the issue causing this?or am I doing something wrong?
thank you a lot !
Seems like the class reference is wrong. The “Get actor of class” node represents a certain first class that exists in the world regardless of how many you put, it always has a reference to the first one only.
The solution that I have is to get all actors of the class as you reference all of them. But make sure you execute it when you have done spawning everyone.
Thank you.
But all enemies move at the same speed.and I have other blueprints which have a reference to a specific enemy.they also get a wrong number.I printed the reference name and velocity together and I’m sure I referenced a correct one.
Is your aim to make them constant speed or to change at a certain time? Because this is a very important decision before you make all this setup. If you want to get the specific class type again, you need to use all actors of the class. You will have to loop them all to execute any task.
Thank your advice again
I already set up the enemy.they have different speed.they all worked fine yesterday.at the time I get velocity from character movement component. But now I change it to pawn. and then the velocity is broken now. I have no idea why.
You might want to change it to character class rather than the pawn class type. I can see that your character possesses the movement component, so it must be a child class from the character class. So, just change it to character, and it should do the trick.
if I uncheck the”use acceleration for paths” it will return wrong velocity.so I check it on.it works now.velocity has no problem.though I don’t know what the option means.
Anyways thank you for your reply.