(SOLVED) Need help with Script that is supposed to get components of an AI and change them
I have a Trigger parented to an AI Gameobject. The Script which is on the Trigger is supposed to, On Trigger Enter, change the Walk Speed.
I want to change the "Move Speed Multiplier" and the "Anim Speed Multiplier" variables upon Trigger Enter
But I'm new to programming, so if you send some script, it would be very nice to explain how to set it up and what variables to use.
If you have an idea on how to solve this problem, I would be so happy if you could help me!
If you need further information, just ask for it. I will answer in notime!
Answer by Cuttlas-U · Sep 09, 2017 at 07:31 PM
hi; what do u need exactly ? about Triggers i think there is sample inside unity document but if u want better sample please explain more;
I want to change the ($$anonymous$$ovement speed) variables of an AI Controller if the player enters the (to the AI GameObject attached) Trigger The Trigger moves with the AI, and the AI moves towards the player I want the AI to get faster (movement) if the player is in the Trigger, though I don't know how to do that through script, I don't know how to edit the variables
hi again ;
void OnTriggerEnter(Collider other)
{
movespeed -= 10;
}
this is a script for trigger enter and reduce a movespeed variable by 10; u can put this on trigger object script ;
so thats the idea but did u create a trigger?
I did create a sphere parented to the AI GameObject (which is moving towards the player) The "IsTrigger" Boolean is true.