Philoupe Posted March 21, 2016 Share Posted March 21, 2016 Hi, I'm planing to create some additional missions for GTA V, but I didn't found anything about envents like entering a zone, so I wonder if that was possible with the ScriptHook SDK. My goal is to start the mission when you enter a specific zone and not being forced to check you position every frame. Did anyone found something about it ?Thanks in advance. Link to comment Share on other sites More sharing options...
jedijosh920 Posted March 22, 2016 Share Posted March 22, 2016 Ha, came from Unity? I'm learning and making games with it too. Anyways, try checking the distance between coordinates, should do what you want. Link to comment Share on other sites More sharing options...
Philoupe Posted March 22, 2016 Author Share Posted March 22, 2016 I came from lot of thing but yeah, I made some game with Unity I know that I can check distance, but it's not very powerful and it's à little dirty. The fact is, I want to start a mission by entering a marker, and to do that I would need to check position every time if I can't use events. Thanks in advance. Link to comment Share on other sites More sharing options...
InfamousSabre Posted March 22, 2016 Share Posted March 22, 2016 (edited) You have to check position every frame (or every other frame, if you want). It isn't dirty. What do you think Unity does underneath those events? Checks position. Edited March 22, 2016 by InfamousSabre Link to comment Share on other sites More sharing options...
Philoupe Posted March 22, 2016 Author Share Posted March 22, 2016 Isn't it too heavy to get position at each frames ? Unity check position but I though he get the position only once by object, group object by locations approximations and compare distance only when the 2 objects are in the same ( or surrounding ) areas. It isn't very dirty to get position for one script but if there is multiple scripts using players position to calculate distance, it isn't very optimized. Thanks. Link to comment Share on other sites More sharing options...
jedijosh920 Posted March 22, 2016 Share Posted March 22, 2016 (edited) Nah it's fine just use position distance, and I noticed the function from Unity http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerEnter.html because I was messing with it earlier. EDIT: Now that I think of it, you can probably use one of the many collision functions as well or ray cast. Edited March 22, 2016 by jedijosh920 Link to comment Share on other sites More sharing options...
InfamousSabre Posted March 22, 2016 Share Posted March 22, 2016 Getting position isnt heavy at all. Its just reading 3 floats from memory. If youre really concerned, just do it every other frame or something. If youre concerned about checking distance being a heavy calculation, just skip the sqrt operations and check for your distance, squared. Link to comment Share on other sites More sharing options...
R3QQ Posted March 23, 2016 Share Posted March 23, 2016 (edited) I ran this in a loop Vector3 coords = ENTITY::GET_ENTITY_COORDS(playerPed, true); 500000 times. It took 63 ms. GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(100, 100, 100, 1000, 1500, 2500, 1); // 5 million times, 547 ms SYSTEM::VDIST(100, 100, 100, 1000, 1500, 2500); // 5 million times, 550 ms My computer is 8 years old. Edited March 23, 2016 by R3QQ Fireboyd78 1 Link to comment Share on other sites More sharing options...
Philoupe Posted March 23, 2016 Author Share Posted March 23, 2016 (edited) It's wierd that GET_DISTANCE_BETWEEN_COORDS is faster than VDIST when the first one should do the sqrt function, and the vdist don't. And 550ms can appears small but I just remember that you game should do all (Not only yours) calculations in 16ms to be at 60FPS. EDIT : And if I had events, i could avoid all of this : PLAYER::PLAYER_ID(); PLAYER::GET_PLAYER_PED(player); ENTITY::GET_ENTITY_COORDS(playerPed, true); SYSTEM::VDIST(playerPos.x, playerPos.y, playerPos.z, 1000, 1500, 2500); (because, when the user is not near the target, I don't need him.) Thanks. Edited March 23, 2016 by Philoupe Link to comment Share on other sites More sharing options...
InfamousSabre Posted March 23, 2016 Share Posted March 23, 2016 (edited) It's wierd that GET_DISTANCE_BETWEEN_COORDS is faster than VDIST when the first one should do the sqrt function, and the vdist don't. And 550ms can appears small but I just remember that you game should do all (Not only yours) calculations in 16ms to be at 60FPS. EDIT : And if I had events, i could avoid all of this : PLAYER::PLAYER_ID(); PLAYER::GET_PLAYER_PED(player); ENTITY::GET_ENTITY_COORDS(playerPed, true); SYSTEM::VDIST(playerPos.x, playerPos.y, playerPos.z, 1000, 1500, 2500); (because, when the user is not near the target, I don't need him.) Thanks. You dont need natives to check distance. Just check it yourself. Again. Even with events you wouldn't be avoiding anything. I don't know how much more plainly I can say this. The operations would happen behind-the-scenes in order for the event to ever fire. Edited March 23, 2016 by InfamousSabre Link to comment Share on other sites More sharing options...
Philoupe Posted March 23, 2016 Author Share Posted March 23, 2016 You cold avoid most of the calls.Instad of calling : PLAYER::PLAYER_ID(); PLAYER::GET_PLAYER_PED(player); ENTITY::GET_ENTITY_COORDS(playerPed, true);for each scripts you would only call them once.And you could define zones and only check distance by zones if your script subbscribed on events by zones.As VDIST seems to be the distance calculation without the sqrt function, I don't think I can do something faster. Thanks Link to comment 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