Jump to content
Pvt.Chiken

Is there a way to freeze rotation with attachToRelative function?

Recommended Posts

I'm trying to attach a rather large object to a helicopter, essentially a spaceship. I did that using BIS_fnc_attachToRelative function and it works. The problem is, however, AI can't fly smoothly, and it looks extremely weird when a huge spaceship starts shaking all over the place. I need to know if there is a way to freeze the spaceship's rotation on pitch axis and roll axis so that it only turns together with the helicopter while generally remaining in the same orientation.

Share this post


Link to post
Share on other sites

Try using enableSimulation false on the spaceship, and then it hopefully won't affect physics of object it is attached to.  If that does not work out, possibly setMass on spaceShip to low number might reduce its physics reactions.  Just some ideas, good luck.  Post a pic of your fun task.  🙂

Share this post


Link to post
Share on other sites
21 hours ago, johnnyboy said:

Try using enableSimulation false on the spaceship, and then it hopefully won't affect physics of object it is attached to.  If that does not work out, possibly setMass on spaceShip to low number might reduce its physics reactions.  Just some ideas, good luck.  Post a pic of your fun task.  🙂

I disabled simulation on the spaceship, but it still doesn't prevent it from rotating. I attached it to the invisible helicopter flying above it so that it can fly around the map. The problem is, due to AI's way of piloting things, it rotates in a very unnatural way along with the helicopter. I need to find a way to freeze the rotation so that the spaceship would follow the helicopter but not rotate with it.
https://imgur.com/a/xk71XGq - pictures of it on imgur.

Share this post


Link to post
Share on other sites

AFAIK, using any "attach" command/function will  result in the behavior you are seeing.

 

I did something similar back in A2 using a combination of visiblePositionASL (maybe new command getPosASLVisual is better?) and setVelocityTransformation. Math is required.

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, Harzach said:

Math is required.

Ugh, math, that's where you lose me.  setVelocityTransformation is probably the way to go (its what BIS_fnc_unitPlay uses I believe),  but a similar idea below might work and is easier on my brain.  Before running it place the ufo where  you want in relation to hidden helicopter (and name ufo myUFO and helicopter myHeli).

onEachFrame 
{
	private _vms = getVelocityModelSpace myHeli;
	myUfo setVectorDirAndUp [vectorDir myHeli,vectorUp myHeli]; 
	myUfo setVelocityModelSpace _vms;
};

This is untested, but easy to test and see if it works.  If it does work I would convert it from using onEachFrame to using an EachFrame missionEventHandler instead.

 

If you don't like the space ship's pitch to match the heli's you could use vectorUp surfaceNormal instead and the pitch would be parallel to the terrain below.

 

Speaking of BIS_fnc_unitPlay, if the space ship is only going to fly a predetermined path, you could run BIS_fnc_unitCapture on a helicopter to pre-record a path, then in the mission call BIS_fnc_unitPlay using the Space Ship instead of the heli.  Another possibility.

  • Like 1

Share this post


Link to post
Share on other sites
5 minutes ago, johnnyboy said:

If you don't like the space ship's pitch to match the heli's you could use vectorUp surfaceNormal instead and the pitch would be parallel to the terrain below.

 

Or if you just want it to stay level, use [0,0,1]:

onEachFrame 
{
	private _vms = getVelocityModelSpace myHeli;
	myUfo setVectorDirAndUp [vectorDir myHeli,[0,0,1]]; 
	myUfo setVelocityModelSpace _vms;
};


 

  • Like 1

Share this post


Link to post
Share on other sites

And I just remembered a 3rd option, but its only good for a straight fly by.  Something I made in 2016!  My how time flys by:

 

 

Share this post


Link to post
Share on other sites

You can also use commands like https://community.bistudio.com/wiki/addForce to make it hoovering like you want but you mus make whole script for maki ti fly (some simple simulation model ) :) I make some time ago something similar but for submarine it works better than submarineX model but looks more laggy beacouse refresh step was 0.1s, in water is not so needed to use faster but on MP sometimes is visibile (push force moments).

https://steamcommunity.com/sharedfiles/filedetails/?id=2202379374

 

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

×