Jump to content
gitrinec

Slide an object across the ground

Recommended Posts

Is it possible to keep an object next to the ground and move it. Not a setpos but where you can visually see it moving.  Not, walk or drive, etc. Would you have to attachto and hide a different object? 

Share this post


Link to post
Share on other sites
16 hours ago, gitrinec said:

Is it possible to keep an object next to the ground and move it. Not a setpos but where you can visually see it moving.  Not, walk or drive, etc. Would you have to attachto and hide a different object? 

You could always use one of the velocity commands, similar to this:

oneachframe {testObject setVelocity velocity player}

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

Also, setVelocityModelSpace.  Here's the example from wiki:

car setVelocityModelSpace [0, 10, 0]; //pushes car forward in direction car is facing

You can use the one time to bump an object in some direction.  Or use it in onEachFrame as Grump suggested, to continuously move an object at a set speed.

  • Like 1

Share this post


Link to post
Share on other sites

If its just a simple object just use vectorLinearConversion.

Spoiler

h = [] spawn {
	_timeTakenToMove = 10;
	_timeFrom = time;
	_timeTo = _timeFrom + _timeTakenToMove;
	
	_posFrom = player getPos[ 10, getDir player -45 ];
	_posTo = player getPos[ 10, getDir player +45 ];
	
	_object = createVehicle[ "Land_Pillow_camouflage_F", _posFrom, [], 0, "CAN_COLLIDE" ];
	
	while { time <= _timeTo } do {
		_curPos = vectorLinearConversion[ _timeFrom, _timeTo, time, _posFrom, _posTo, true ];
		
		_curPos set[ 2, 0 ];	//0 keep it on the ground
		_object setPosATL _curPos;
		_object setVectorUp surfaceNormal _curPos;	//rotate to match ground normal
	};
	
	_object setPosATL _posTo;	//time finished, just make sure object is at _posTo
};

 

 

  • Like 5
  • Thanks 1

Share this post


Link to post
Share on other sites
On 1/9/2020 at 4:25 PM, Larrow said:

If its just a simple object just use vectorLinearConversion.

  Hide contents


h = [] spawn {
	_timeTakenToMove = 10;
	_timeFrom = time;
	_timeTo = _timeFrom + _timeTakenToMove;
	
	_posFrom = player getPos[ 10, getDir player -45 ];
	_posTo = player getPos[ 10, getDir player +45 ];
	
	_object = createVehicle[ "Land_Pillow_camouflage_F", _posFrom, [], 0, "CAN_COLLIDE" ];
	
	while { time <= _timeTo } do {
		_curPos = vectorLinearConversion[ _timeFrom, _timeTo, time, _posFrom, _posTo, true ];
		
		_curPos set[ 2, 0 ];	//0 keep it on the ground
		_object setPosATL _curPos;
		_object setVectorUp surfaceNormal _curPos;	//rotate to match ground normal
	};
	
	_object setPosATL _posTo;	//time finished, just make sure object is at _posTo
};

 

 

hi,

how is it possible to make this script slide an object between two positions in a loop?

Edited by Alert23

Share this post


Link to post
Share on other sites
Spoiler

h = [] spawn {
	_timeTakenToMove = 10;
	
	_posFrom = player getPos[ 10, getDir player -45 ];
	_posTo = player getPos[ 10, getDir player +45 ];
	
	_object = createVehicle[ "Land_Pillow_camouflage_F", _posFrom, [], 0, "CAN_COLLIDE" ];
	
	while{ true } do {
		_timeFrom = time;
		_timeTo = _timeFrom + _timeTakenToMove;
		
		while { time <= _timeTo } do {
			_curPos = vectorLinearConversion[ _timeFrom, _timeTo, time, _posFrom, _posTo, true ];
			
			_curPos set[ 2, 0 ];	//0 keep it on the ground
			_object setPosATL _curPos;
			_object setVectorUp surfaceNormal _curPos;	//rotate to match ground normal
		};
		
		_object setPosATL _posTo;	//time finished, just make sure object is at _posTo
		
		_tmp = _posFrom;
		_posFrom = _posTo;
		_posTo = _tmp;
	};
};

 

 

  • Like 1
  • Thanks 2

Share this post


Link to post
Share on other sites

@Larrow If BI didn't change the setPos command family then it is not MP friendly. Last time I tested it the executing instance saw the object move smoothly while I saw it warp across the scenery as if only every nth command was broadcasted. This might be because the every frame refers to the frames that the script executor has and not the other clients'. This was like 2 years back though...

 

My two cents would be to use Keyframe Animation.

  • Like 2

Share this post


Link to post
Share on other sites

Both suffer from exactly the same problem. The keyframe animation uses setposASL from the server, the module is server execute only and is server authoritative.

This is me as a client on a local dedicated server.

Tell me which is a timeline keyframe animation and which is my script from above.

  • Like 3

Share this post


Link to post
Share on other sites

Hmm that's not good. Next two ideas:

  1. Run the script on each client remotely with a createVehicleLocal object
  2. Attach the object to an invisible unit, let that unit move from point A to point B
  • Like 2

Share this post


Link to post
Share on other sites

Number 1 is most likely the best option. Still have the server authoritative on when to stop/start the movement but with each client having their own local object and then just use serverTime to sync the vectorLinearConversion across all machines.

  • Like 1

Share this post


Link to post
Share on other sites

how did you go with this?  I'm attempting to set up a hidden panel that slides open when triggered but am having no joy with the animation of moving an object. 

Share this post


Link to post
Share on other sites

 

This is for a vehicle, sorry for such a late reply, was away from editing for a while. The idea was to have a vehicle moving upside down and sliding on its roof.

On 1/18/2020 at 7:43 AM, Larrow said:
  Reveal hidden contents


h = [] spawn {
	_timeTakenToMove = 10;
	
	_posFrom = player getPos[ 10, getDir player -45 ];
	_posTo = player getPos[ 10, getDir player +45 ];
	
	_object = createVehicle[ "Land_Pillow_camouflage_F", _posFrom, [], 0, "CAN_COLLIDE" ];
	
	while{ true } do {
		_timeFrom = time;
		_timeTo = _timeFrom + _timeTakenToMove;
		
		while { time <= _timeTo } do {
			_curPos = vectorLinearConversion[ _timeFrom, _timeTo, time, _posFrom, _posTo, true ];
			
			_curPos set[ 2, 0 ];	//0 keep it on the ground
			_object setPosATL _curPos;
			_object setVectorUp surfaceNormal _curPos;	//rotate to match ground normal
		};
		
		_object setPosATL _posTo;	//time finished, just make sure object is at _posTo
		
		_tmp = _posFrom;
		_posFrom = _posTo;
		_posTo = _tmp;
	};
};

 

 

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×