How to get the angle direction between two entities
2 Attachment(s)
Hello guys
Trying to solve an issue where I can't exactly adjust an entity angle direction to my position. You can see this drawing skills of mine :bacon: to show you what I mean https://i.ibb.co/MNm2ZSN/Untitled.png I found a snippet in the modders community to adjust the entity angle to always face my direction but not when it comes to height difference PHP Code:
I Uploaded a test version, using TR_DidHit() to detect ground and attach it to it. You will notice some issues when going to different level surface. Requires: Left4Dhooks Video showing the test version - YouTube If anyone has a solution, that would be great Thanks |
Re: How to get the angle direction between two entities
Hey. Its a nice drawing, but what's the actual problem?
You say "I can't exactly adjust an entity angle direction to my position", also the title of this post suggests there's a problem with angles, but the linked video shows a problem with Z position. And the 'test version' video doesn't have this problem. In the test version video with the TR_DidHit which I'm now assuming is the code you posted, it seems to work fine ish? When you say 'You will notice some issues', I am not sure what you mean. So where exactly is the problem? What is your desired behavior? I can see however the odd teleporting from 1:22 forward, which is caused by this: PHP Code:
My suggestions are if you want to teleport the pet back if it gets lost, you should check it somehow else. Perhaps create a function to get the distance from the pet to the player, if the distance gets larger than X units, then teleport the pet back. Or think of something better. Is this even required? Can the pet actually get lost? GetDistanceToFloor() doesn't actually get the "distance to the floor". It returns the Z position of where the ray hits, which, looking at the angle should be the ground. So a more proper name would be something like GetGroundPosition(). If you want the pet to have some 'gravity' instead of teleporting instanly to ground level, you could implement a slower increase/decrease of the Z position, and add a jumping animation when increasing it, if such animation exists. |
Re: How to get the angle direction between two entities
Quote:
Since currently what I do, is pushing the prop_dynamic from point 1 to point 2, then point 2 to point 3 etc to achieve an ideal movements. But if we kept adjusting the Z pos every time, it wouldn't be ideal. See this image, I want to tilt it to my next pos, and then push it, instead of adjusting the Z pos https://i.ibb.co/02Q6fdB/test.png Quote:
|
Re: How to get the angle direction between two entities
After much consideration, tilting or adjusting the angle is not a good method, I need as you said to change Z pos.
|
Re: How to get the angle direction between two entities
I may guess that you are trying to implement a sort of NPC? If yes, there is a "monster_generic" entity available in most source engine games which can walk and overcome some dynamic obstacles (barrels and boxes). You could spawn one with "zombie classic" model from HL2 and see if it meets your requirements.
https://developer.valvesoftware.com/...onster_generic On the second level of ze_Castlevania_p1_7 there are knights with swords which walk around and attack players (you can check them on youtube). Implemented with pure mapping. At the beginning of the first level of ze_best_korea_v1 there is a solder who can walk around, jump and attack the players. |
Re: How to get the angle direction between two entities
Quote:
Sadly I'm using L4D2 for this |
Re: How to get the angle direction between two entities
maybe this plugin can give you some hints https://forums.alliedmods.net/showthread.php?p=2768940
|
Re: How to get the angle direction between two entities
You cold check then how the npc implemented in ze_best_korea_v1 and ze_Castlevania_p1_7. They are based on prop_dynamic entities combined with sets of triggers. All of it can be implemented with coding, I believe.
And there is this NPC extension: https://forums.alliedmods.net/showthread.php?t=335156 |
Re: How to get the angle direction between two entities
Thank you guys, I have seen and read all these scripts which all have helped me build some ideas to improve it. Still working on it, hopefully it becomes as I plan. Thanks a lot
|
All times are GMT -4. The time now is 14:57. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.