How to make the npc fight

so like i said im making a special game and I need to make the npc fight when the player is near or when they see the player how do I do that?

Hey, you can do that by attaching the raycast to the NPC and selecting the player as the object. If you need any more help plz let me know. :wink:

can you make a example please thank you

Sorry, I can’t do that because I’m a free user and I have all three games in progress.

Actually, if you give me the link to your game, I can make some changes and send you a screenshot so you can make the permanent changes.

I think you could also use enable block and a proximity block so that it allows the NPC to move when the player is close

But first u gotta disable the NPC’s physics

AIGHT BRO LETS MAKE THIS QUICK COPY MY CODE
Monster code: {“data”:{“behavior”:{“v”:“2”,“nodes”:[{“inputCount”:0,“outputCount”:1,“name”:“Once”,“behaviorType”:“logic.triggers.Once”,“x”:-450,“y”:-192,“group”:“”,“id”:“e599b5c89ce1ec46”,“resetOnLevelStart”:false},{“inputCount”:3,“outputCount”:3,“name”:“Animation”,“behaviorType”:“logic.properties.Animation”,“x”:-180,“y”:-192,“group”:“”,“id”:“e59a17456021b345”,“animationName”:“mosnter walky walky”,“loop”:true,“priority”:0},{“inputCount”:0,“outputCount”:1,“name”:“Always”,“behaviorType”:“logic.triggers.Always”,“x”:-450,“y”:-32,“group”:“”,“id”:“e59b80ac5f0c6846”},{“inputCount”:3,“outputCount”:1,“name”:“Number”,“behaviorType”:“logic.logic.Value”,“x”:-180,“y”:-32,“group”:“”,“id”:“e59bba27c145a246”,“startVal”:20,“tag”:“”,“roundMode”:1},{“inputCount”:3,“outputCount”:3,“name”:“Velocity”,“behaviorType”:“logic.properties.Physics”,“x”:180,“y”:-32,“group”:“”,“id”:“e59c051ba7f1b44b”},{“inputCount”:0,“outputCount”:1,“name”:“Collision”,“behaviorType”:“logic.triggers.Collision”,“x”:-180,“y”:320,“group”:“”,“id”:“e59d9a4a466cf04b”,“targetClassId”:0,“targetEntityId”:0,“collisionFilter”:12,“collideWithEntity”:false,“delay”:0},{“inputCount”:3,“outputCount”:3,“name”:“Flip”,“behaviorType”:“logic.properties.Flip”,“x”:180,“y”:64,“group”:“”,“id”:“e59ec6c74a476e45”},{“inputCount”:3,“outputCount”:2,“name”:“RayCast”,“behaviorType”:“logic.components.RayCast”,“x”:-180,“y”:64,“group”:“”,“id”:“e5a30ad2383dbc40”,“targetClassId”:0,“direction”:22,“length”:55,“earlyOut”:false,“oX”:0,“oY”:0},{“inputCount”:3,“outputCount”:2,“name”:“RayCast”,“behaviorType”:“logic.components.RayCast”,“x”:-180,“y”:192,“group”:“”,“id”:“e5a31285be40674b”,“targetClassId”:0,“direction”:158,“length”:55,“earlyOut”:false,“oX”:0,“oY”:0},{“inputCount”:0,“outputCount”:1,“name”:“Collision”,“behaviorType”:“logic.triggers.Collision”,“x”:-450,“y”:416,“group”:“”,“id”:“e5a7cf317e0d3b44”,“targetClassId”:16976731,“targetEntityId”:0,“collisionFilter”:1,“collideWithEntity”:false,“delay”:0},{“inputCount”:1,“outputCount”:1,“name”:“Destroyer”,“behaviorType”:“logic.components.Destroyer”,“x”:-180,“y”:416,“group”:“”,“id”:“e5a8e61e21eeec44”},{“inputCount”:0,“outputCount”:1,“name”:“Collision”,“behaviorType”:“logic.triggers.Collision”,“x”:-450,“y”:544,“group”:“”,“id”:“e5f15a2fd069a64b”,“targetClassId”:16981959,“targetEntityId”:0,“collisionFilter”:15,“collideWithEntity”:false,“delay”:0},{“inputCount”:2,“outputCount”:1,“name”:“Emitter”,“behaviorType”:“logic.components.Emitter”,“x”:0,“y”:416,“group”:“”,“id”:“e5f8659b3c058f4c”,“entityClassId”:16981987,“maxAge”:30,“force”:2,“rotate”:false,“angle”:0,“independent”:false,“oX”:0,“oY”:0}],“links”:[{“input_id”:“e59a17456021b345i0”,“output_id”:“e599b5c89ce1ec46o0”},{“input_id”:“e59a17456021b345i0”,“output_id”:“e599b5c89ce1ec46o0”},{“input_id”:“e59bba27c145a246i1”,“output_id”:“e59b80ac5f0c6846o0”},{“input_id”:“e5a30ad2383dbc40i2”,“output_id”:“e59b80ac5f0c6846o0”},{“input_id”:“e5a31285be40674bi2”,“output_id”:“e59b80ac5f0c6846o0”},{“input_id”:“e59bba27c145a246i1”,“output_id”:“e59b80ac5f0c6846o0”},{“input_id”:“e59c051ba7f1b44bi2”,“output_id”:“e59bba27c145a246o0”},{“input_id”:“e59c051ba7f1b44bi2”,“output_id”:“e59bba27c145a246o0”},{“input_id”:“e59ec6c74a476e45i2”,“output_id”:“e59d9a4a466cf04bo0”},{“input_id”:“e59ec6c74a476e45i0”,“output_id”:“e5a30ad2383dbc40o1”},{“input_id”:“e59ec6c74a476e45i1”,“output_id”:“e5a31285be40674bo1”},{“input_id”:“e59ec6c74a476e45i2”,“output_id”:“e59d9a4a466cf04bo0”},{“input_id”:“e5a30ad2383dbc40i2”,“output_id”:“e59b80ac5f0c6846o0”},{“input_id”:“e59ec6c74a476e45i0”,“output_id”:“e5a30ad2383dbc40o1”},{“input_id”:“e5a31285be40674bi2”,“output_id”:“e59b80ac5f0c6846o0”},{“input_id”:“e59ec6c74a476e45i1”,“output_id”:“e5a31285be40674bo1”},{“input_id”:“e5a8e61e21eeec44i0”,“output_id”:“e5a7cf317e0d3b44o0”},{“input_id”:“e5a8e61e21eeec44i0”,“output_id”:“e5a7cf317e0d3b44o0”},{“input_id”:“e5a8e61e21eeec44i0”,“output_id”:“e5f15a2fd069a64bo0”},{“input_id”:“e5f8659b3c058f4ci0”,“output_id”:“e5a8e61e21eeec44o0”},{“input_id”:“e5a8e61e21eeec44i0”,“output_id”:“e5f15a2fd069a64bo0”},{“input_id”:“e5f8659b3c058f4ci0”,“output_id”:“e5a8e61e21eeec44o0”}]}}}
Players Code: {“data”:{“behavior”:{“v”:“2”,“nodes”:[{“inputCount”:3,“outputCount”:1,“name”:“Number”,“behaviorType”:“logic.logic.Value”,“x”:-90,“y”:192,“group”:“e5e3ba42383c6c4e”,“id”:“e0bb1aac8f16d949”,“startVal”:3,“tag”:“HP”,“roundMode”:1},{“inputCount”:0,“outputCount”:1,“name”:“Collision”,“behaviorType”:“logic.triggers.Collision”,“x”:-450,“y”:192,“group”:“e5e3ba42383c6c4e”,“id”:“e0bbe31b4363154f”,“targetClassId”:16977005,“targetEntityId”:0,“collisionFilter”:15,“collideWithEntity”:false,“delay”:0},{“inputCount”:3,“outputCount”:1,“name”:“Number”,“behaviorType”:“logic.logic.Value”,“x”:-270,“y”:192,“group”:“e5e3ba42383c6c4e”,“id”:“e0bc92650fc97649”,“startVal”:-1,“tag”:“DAMAGE”,“roundMode”:1},{“inputCount”:4,“outputCount”:4,“name”:“Label”,“behaviorType”:“logic.hud.Label2”,“x”:90,“y”:192,“group”:“e5e3ba42383c6c4e”,“id”:“e0be549048e47e47”,“text”:“3 “,“textColor”:14492474,“fontName”:“oduda”,“scale”:10,“textAlign”:“left”,“maxWidth”:18,“xO”:142,“yO”:5,“pin”:false,“alpha”:100,“kerning”:0},{“inputCount”:4,“outputCount”:4,“name”:“Label”,“behaviorType”:“logic.hud.Label2”,“x”:270,“y”:192,“group”:“e5e3ba42383c6c4e”,“id”:“e0bfdd447af7224e”,“text”:“HEALTH”,“textColor”:16517456,“fontName”:“oduda”,“scale”:10,“textAlign”:“left”,“maxWidth”:0,“xO”:5,“yO”:3,“pin”:false,“alpha”:100,“kerning”:0},{“inputCount”:1,“outputCount”:1,“name”:“RestartGame”,“behaviorType”:“logic.gameflow.RestartGame”,“x”:270,“y”:352,“group”:“e5e3ba42383c6c4e”,“id”:“e0c5630c1f579c41”},{“gateVal”:1,“mode”:“less than”,“inputCount”:2,“outputCount”:2,“name”:“Filter”,“behaviorType”:“logic.logic.Filter2”,“x”:90,“y”:320,“group”:“e5e3ba42383c6c4e”,“id”:“e0c7088e95a6ef43”},{“inputCount”:3,“outputCount”:4,“name”:“SoundEffect”,“behaviorType”:“logic.components.SoundEffect”,“x”:-270,“y”:288,“group”:“e5e3ba42383c6c4e”,“id”:“e566ec19534c0245”,“sound”:null,“loop”:false,“volume”:100,“url”:null,“soundName”:“alert sound effect 19”,“soundURL”:”/effects/alert/HoverOver_Generic_Blip_02.wav.mp3”},{“inputCount”:0,“outputCount”:1,“name”:“Collision”,“behaviorType”:“logic.triggers.Collision”,“x”:-450,“y”:320,“group”:“e5e3ba42383c6c4e”,“id”:“e5aa61957ce50547”,“targetClassId”:16981725,“targetEntityId”:0,“collisionFilter”:15,“collideWithEntity”:false,“delay”:0}],“links”:[{“input_id”:“e0bb1aac8f16d949i2”,“output_id”:“e0bc92650fc97649o0”},{“input_id”:“e0be549048e47e47i0”,“output_id”:“e0bb1aac8f16d949o0”},{“input_id”:“e0c7088e95a6ef43i1”,“output_id”:“e0bb1aac8f16d949o0”},{“input_id”:“e0bc92650fc97649i1”,“output_id”:“e0bbe31b4363154fo0”},{“input_id”:“e566ec19534c0245i0”,“output_id”:“e0bbe31b4363154fo0”},{“input_id”:“e0bc92650fc97649i1”,“output_id”:“e0bbe31b4363154fo0”},{“input_id”:“e0bc92650fc97649i1”,“output_id”:“e5aa61957ce50547o0”},{“input_id”:“e0bb1aac8f16d949i2”,“output_id”:“e0bc92650fc97649o0”},{“input_id”:“e0be549048e47e47i0”,“output_id”:“e0bb1aac8f16d949o0”},{“input_id”:“e0c5630c1f579c41i0”,“output_id”:“e0c7088e95a6ef43o0”},{“input_id”:“e0c7088e95a6ef43i1”,“output_id”:“e0bb1aac8f16d949o0”},{“input_id”:“e0c5630c1f579c41i0”,“output_id”:“e0c7088e95a6ef43o0”},{“input_id”:“e566ec19534c0245i0”,“output_id”:“e0bbe31b4363154fo0”},{“input_id”:“e566ec19534c0245i0”,“output_id”:“e5aa61957ce50547o0”},{“input_id”:“e0bc92650fc97649i1”,“output_id”:“e5aa61957ce50547o0”},{“input_id”:“e566ec19534c0245i0”,“output_id”:“e5aa61957ce50547o0”}]}}}
note: i may did some few mistakes but if its confusing press on this sus/helpful link
Intro to Flowlab Part 9: Wandering Enemies - YouTube

1 Like

First of all, you need to put all code after you put three of these ` [backticks] in your post.
example
If you don’t, the forums will automatically convert all the " [quotes] into ones that can’t be pasted back into Flowlab.

Second of all, help is always appreciated but please check the last post’s date next time because the person who asked for help here most likely isn’t active anymore. You can see the newest people who need help by clicking the latest button on the main forums page.

You can also change your forums homepage to be latest or something else by changing your settings in the preferences section by clicking your profile picture.