draoth 13 Posted January 13, 2018 Hello everyone I'm trying to create a mission where vehicles are constantly driving in the area of the players. I've accomplished it by creating a random vehicle min. 1000m and max. 2000m away from the player. This vehicle then gets a random waypoint somewhere on the map, but this means that they can drive away from the player and they won't even see it making it useless. So is there a way i can make it so the random waypoint will always be sorta crossing the player? (The player just has too hear/see it) If anyone has an idea how i could make this that would be great! Here's a little illustration if my explanation was too vague. Share this post Link to post Share on other sites
pierremgi 4853 Posted January 14, 2018 What is your script right now? Are you spawning the vehicle anywhere (in forest, rocks, sea...) or are you able to spawn it on roads segment or at safe position? 1 Share this post Link to post Share on other sites
draoth 13 Posted January 14, 2018 20 minutes ago, pierremgi said: What is your script right now? Are you spawning the vehicle anywhere (in forest, rocks, sea...) or are you able to spawn it on roads segment or at safe position? The Vehicle currently spawns on a road segment minimal 1km away from the player and the driver has a waypoint with safe behaviour on it leading tot a random location on the map. Share this post Link to post Share on other sites
cosmic10r 2331 Posted January 14, 2018 Is there some reason you wouldnt just add a middle waypoint with the waypoint location set as _playerWaypointPos = getpos player; Share this post Link to post Share on other sites
pierremgi 4853 Posted January 14, 2018 16 hours ago, draoth said: The Vehicle currently spawns on a road segment minimal 1km away from the player and the driver has a waypoint with safe behaviour on it leading tot a random location on the map. So, you can find a position in direction of player, for 1.x distance. use vectorFromTo and distance: _destination = player getpos [-1.2 * (_startpos distance2D player), player getRelDir_startPos] ; // corrected version then safe position and or nearest roads if any, or equivalent. 1 Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted January 14, 2018 Or alternatively (and probably easier to read: _distance = random 1000; _dir = random 360; _relpos = player getRelPos [_distance, _dir]; Will return a position within 1000m somewhere around the player. Cheers 1 Share this post Link to post Share on other sites
draoth 13 Posted January 14, 2018 First of all, Thanks everybody for helping me. 9 hours ago, pierremgi said: So, you can find a position in direction of player, for 1.x distance. use vectorFromTo and distance: _destination = player getpos [1.2 * (_startpos distance2D player),_startPos vectorFromTo player] ; then safe position and or nearest roads if any, or equivalent. So if i read this right (I probably didn't), this will create a destination that will be somewhere around the player. But i'd like if the car just drives somewhere trough the 1km area around the player to get to his waypoint that is further away. I'm not that familiar with the vectorFromTo so can you explain how it works? 7 hours ago, Grumpy Old Man said: Or alternatively (and probably easier to read: _distance = random 1000; _dir = random 360; _relpos = player getRelPos [_distance, _dir]; Will return a position within 1000m somewhere around the player. Cheers Thanks for your time but this is also not exactly what i meant either. I'd like the vehicle to drive past the player but just to get for example to the other side of the island. (And despawn when it's 3km away from it) I want to make this script so it feels like Altis is populated. Forgive me if i'm just an idiot that doesn't understand what you guys just wrote down, but i'm trying to learn so every explanation is very useful for me to learn. Share this post Link to post Share on other sites
pierremgi 4853 Posted January 14, 2018 1 minute ago, draoth said: So if i read this right (I probably didn't), this will create a destination that will be somewhere around the player. But i'd like if the car just drives somewhere trough the 1km area around the player to get to his waypoint that is further away. I'm not that familiar with the vectorFromTo so can you explain how it works? No, that's the GOM solution. Mine is placing a position at the opposite of start one, referring to player. See BIKI for any command you like and pay attention for syntax. 1 Share this post Link to post Share on other sites
draoth 13 Posted January 14, 2018 5 minutes ago, pierremgi said: No, that's the GOM solution. Mine is placing a position at the opposite of start one, referring to player. See BIKI for any command you like and pay attention for syntax. That's exactly what i need. Thank you for being so active on this forum. I like to learn scripting just by doing something out of the box and figuring out what i need for it. But sometimes i can't seem to figure it out by myself. Thanks again Pierre. Share this post Link to post Share on other sites
pierremgi 4853 Posted January 14, 2018 Bah, I spoke about syntax, and I didn't check my code; Don't use vectorFromDir here but getRelDir instead. 1 Share this post Link to post Share on other sites
draoth 13 Posted January 14, 2018 Just now, pierremgi said: Bah, I spoke about syntax, and I didn't check my code; Don't use vectorFromDir here but getRelDir instead. No worries, thanks! Share this post Link to post Share on other sites
draoth 13 Posted January 14, 2018 2 minutes ago, pierremgi said: Bah, I spoke about syntax, and I didn't check my code; Don't use vectorFromDir here but getRelDir instead. _Spawnlocation = _this select 0; //Starting location _Location = player getpos [1.2 * (_Spawnlocation distance2D player),player getRelDir _spawnlocation] ; _Road = [_Location, 1000, []] call BIS_fnc_nearestRoad; _Destination = getPos _Road; This should be correct right? Share this post Link to post Share on other sites
pierremgi 4853 Posted January 14, 2018 Just use -1.2 instead of 1.2 , due to the direction. (here 1.2 means 200 m far from player if the distance between player and start position is 1000 m. 1 Share this post Link to post Share on other sites