weitoast Posted April 20, 2023 Share Posted April 20, 2023 I have added a level component to the player and stated that on the screen, the level can increase the attack range of the spear, but due to an error in the red circle, how to write it to represent the player himself or a specific individual creature I want to specify Link to comment https://forums.kleientertainment.com/forums/topic/147279-how-to-indicate-a-prefablike-player/ Share on other sites More sharing options...
-LukaS- Posted April 23, 2023 Share Posted April 23, 2023 'owner' doesn't exist in 'modispear' functions scope. The way you're trying to increase spears range is wrong too. 'AddPrefabPostInit' runs on entity creation so it would not dynamically change the range with the players level. A better way of doing that would be to use 'AddPlayerPostInit' and listen to the 'onequip', 'onunequip' events and then check whether the player has a spear equipped and changing THEIR range instead of the weapon. You can do that with 'inst.components.combat:SetRange(range)' Link to comment https://forums.kleientertainment.com/forums/topic/147279-how-to-indicate-a-prefablike-player/#findComment-1631531 Share on other sites More sharing options...
weitoast Posted April 28, 2023 Author Share Posted April 28, 2023 On 4/23/2023 at 9:50 PM, -t- said: 'owner' doesn't exist in 'modispear' functions scope. The way you're trying to increase spears range is wrong too. 'AddPrefabPostInit' runs on entity creation so it would not dynamically change the range with the players level. A better way of doing that would be to use 'AddPlayerPostInit' and listen to the 'onequip', 'onunequip' events and then check whether the player has a spear equipped and changing THEIR range instead of the weapon. You can do that with 'inst.components.combat:SetRange(range)' Thank you for reminding me. Regarding the attack distance setting, I used inst: DoPeriodicTask (0.5), which constantly changes the attack distance of the spear. I forgot to write it here. However, compared to equipping the spear, I prefer to implement my code by detecting variable changes. Is there a way to pass player parameters without using any functions related to the player? For example, constantly searching for all creatures in the picture and then locking in creatures with player tags, but I don't know how to write Link to comment https://forums.kleientertainment.com/forums/topic/147279-how-to-indicate-a-prefablike-player/#findComment-1632383 Share on other sites More sharing options...
-LukaS- Posted April 29, 2023 Share Posted April 29, 2023 In this situation inst:DoPeriodicTask(0.5) won't actually change your spears range because, as I said before you're using AddPrefabPostInit which only runs once. I don't exactly understand what you're trying to achieve with searching for `player` creatures, but you could probably use TheSim:FindEntities() or FindEntity. There is also a table of all connected players called AllPlayers. Link to comment https://forums.kleientertainment.com/forums/topic/147279-how-to-indicate-a-prefablike-player/#findComment-1632640 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now