Jump to content

Recommended Posts

In an effort to be useful for a change, I've decided to offer help to whomever needs it.

 

Technologies supported:

  • SQF
  • C# / ASP.NET / WPF / WinForms / (a bit of Xamarin)
  • (a bit of C++)
  • (a bit of OpenGL / GLSL)
  • SQL
  • HTML
  • CSS
  • Javascript (including the JQuery library)

 

Just some simple guidelines to follow:

  • Describe the problem with as much detail as possible.
  • Describe your attempts at solving the problem (if any) so I can get a better idea of where you're stuck or to offer guidance on certain topics.
  • If needed, post images to help describe the problem in further detail.
  • Post code snippets within the forum's code tags, or use Pastebin:
RemoveOldGib =
{
    if(count Gibs > 0) then
    {
        _gib = Gibs select 0;
        deleteVehicle _gib;
        Gibs deleteAt 0;
    };
};


 

Example Post:

 

 

Sup Zooloo, I'm trying to place an object on the ground using setPosASL, but the object is standing straight up and is not aligning to the surface.

I've tried using setDir, but it only rotates the object around the Z-Axis.

_object = "MyBox" createVehicle [0, 0, 0];
_object setDir (random 360);
_object setPosASL (position _boxSpawnPositionLogic);

pls halp

 

Hey Bob, in order to align your object to the ground, you can use setVectorUp along with surfaceNormal.

_object = "MyBox" createVehicle [0, 0, 0];
_object setDir (random 360);
_object setPosASL (position _boxSpawnPositionLogic);
_object setVectorUp (surfaceNormal (position _object));

This will allow you to set the "Up" direction of the object to be the same as the face of the terrain the object currently resides at.

  • Like 1

Share this post


Link to post
Share on other sites

Hey Zooloo,

 

Here is a good question for you that I cant quite think of a operating theory on.

 

A player is looking at an object I wish to use attachto with.  What would be the best way to determine where exactly the player is looking to attach an object to?   I know how to get the coordinates relative to the world, but not sure how to do it relative to the objects center, since attachto uses an offset.

 

An better example, a player is looking at the passenger door of a SUV.  I need to attachto a satchel charge.

  • Like 1

Share this post


Link to post
Share on other sites

Hey Zooloo,

 

Here is a good question for you that I cant quite think of a operating theory on.

 

A player is looking at an object I wish to use attachto with.  What would be the best way to determine where exactly the player is looking to attach an object to?   I know how to get the coordinates relative to the world, but not sure how to do it relative to the objects center, since attachto uses an offset.

 

An better example, a player is looking at the passenger door of a SUV.  I need to attachto a satchel charge.

 

Hi wyattwic,

 

You can use the lineIntersectsSurfaces command to get objects that intersect a line and the world position those objects were intersected at. With this data, you can place an object at the intersection position, then attach your object to the intersected object without having to pass a relative offset, as attachTo will position the attached object relative to the initial position the object was attached to.

In practice, you'd check any intersections between the player's eyePos and a position a bit ahead of the player. Use the data from the first intersection which contains the intersection position of the object (in world space), the surface normal of the intersected position, and the object that was intersected.

 

Below is a full example which you can run via the debug console or place in an init.sqf. The only thing missing is the alignment to the surface -- it's a bit tricky when combined with attachTo, but nonetheless, still possible with a bit of math.

CanPlaceObject = false;
IntersectionPosition = [0, 0, 0];
IntersectionNormal = [0, 0, 0];
IntersectionObject = objNull;
PreviewObject = "Sign_Arrow_Cyan_F" createVehicle [0, 0, 0];

[] spawn
{
    _intersectionDistance = 10;
    while {alive player} do
    {
        _intersectionDistance = 3;
        _beginPosition = eyePos player;
        _endPosition = [0, 0, 0];
        if(weaponLowered player) then
        {
            _endPosition = _beginPosition vectorAdd ((eyeDirection player) vectorMultiply _intersectionDistance);
        }
        else
        {
            _endPosition = _beginPosition vectorAdd ((player weaponDirection (currentWeapon player)) vectorMultiply _intersectionDistance);
        };

        _intersections = lineIntersectsSurfaces [
    		_beginPosition,
    		_endPosition,
    		player,
    		vehicle player,
    		true,
    		1,
    		"GEOM",
    		"NONE"
    	];
    	if (count _intersections > 0) then
        {
            _intersection = _intersections select 0;
            IntersectionPosition = _intersection select 0;
            IntersectionNormal = _intersection select 1;
            IntersectionObject = _intersection select 2;
            CanPlaceObject = true;
            PreviewObject setPosASL IntersectionPosition;
            PreviewObject setVectorUp IntersectionNormal;
        }
        else
        {
            CanPlaceObject = false;
        };
        sleep 0.01;
    };
};

player addAction ["Place Mine", {
    _mine = "APERSMine_Range_Ammo" createVehicle [0, 0, 0];
    _mine setPosASL IntersectionPosition;
    _mine attachTo [IntersectionObject];
},
[],
1.5,
true,
true,
"",
"CanPlaceObject"];

  • Like 1

Share this post


Link to post
Share on other sites

Hi Zooloo,

 

I'm currently making a mission to play with some friends on a dedicated server.  Basically what I'm trying to make happen is for a specific object to be picked up somewhere on the map, then carried in someone's inventory to somewhere else on the map, then when it is placed down in a specific area it fires a script.

 

So far I placed trigger with a 10m radius as the delivery zone (named zone1), the object is called package, and tried the following code in a game logic.

if (isServer and package inArea zone1) then {execVM "myscript.sqf"};

So far nothing happens at all.  I know it's not the script that is being executed as that works, so I must not be doing something right with the inArea?

 

In an ideal world I would like the script to not be executed until the object is placed on the ground, rather than when the person with the item in their inventory enters the trigger, but I could live with it.

  • Like 1

Share this post


Link to post
Share on other sites

Hi Zooloo,

 

I'm currently making a mission to play with some friends on a dedicated server.  Basically what I'm trying to make happen is for a specific object to be picked up somewhere on the map, then carried in someone's inventory to somewhere else on the map, then when it is placed down in a specific area it fires a script.

 

So far I placed trigger with a 10m radius as the delivery zone (named zone1), the object is called package, and tried the following code in a game logic.

if (isServer and package inArea zone1) then {execVM "myscript.sqf"};

So far nothing happens at all.  I know it's not the script that is being executed as that works, so I must not be doing something right with the inArea?

 

In an ideal world I would like the script to not be executed until the object is placed on the ground, rather than when the person with the item in their inventory enters the trigger, but I could live with it.

 

Hi Cunners, I've prepared a special mission for you. 

I've tested out your condition with a trigger and it worked fine. I suspect your trigger size may not be adequate, or the type and activation properties are not set to a setting that would fire off in your mission.

Check the two comment blurbs within the editor on details about the trigger, and finally open up the trigger and examine its properties.

 

Download the mission here: http://files.bitdungeon.org/ArmA/Examples/Zooloo75_Cunners_Package.VR.zip

 

Hopefully you can learn from it and adapt it to your scenario.

 

ZdXpA0x.jpg?1

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for taking the time to do that Zooloo.  Unfortunately though I can't seem to open the mission, I get a "Error when loading the scenerio!"?

Share this post


Link to post
Share on other sites

Thanks for taking the time to do that Zooloo.  Unfortunately though I can't seem to open the mission, I get a "Error when loading the scenerio!"?

Odd. Are you on the main or dev branch? I made this on dev with no addons enabled.

Share this post


Link to post
Share on other sites

Oh I'm on the main build, downloading the dev now and will give it a go

Share this post


Link to post
Share on other sites

Ok cool man that works now I'm using the Dev build and I did have the bits in the wrong parts in the trigger! 

 

Out of interest I assume that when you pick up an object and actually put it in an intentory (either a player's backpack, or as I was hoping to do using ACE to load an object into the vehicle drive it across the map then unload it in the trigger area rather than just balancing it on the back of a truck) it deletes the variable name, as when I try to do this using this method it doesn't work?

  • Like 1

Share this post


Link to post
Share on other sites

Ok cool man that works now I'm using the Dev build and I did have the bits in the wrong parts in the trigger! 

 

Out of interest I assume that when you pick up an object and actually put it in an intentory (either a player's backpack, or as I was hoping to do using ACE to load an object into the vehicle drive it across the map then unload it in the trigger area rather than just balancing it on the back of a truck) it deletes the variable name, as when I try to do this using this method it doesn't work?

 

There are many ways to go about this. If you have just an ordinary object on the map, like a barrel, documents, or something, you of course can't put that in your backpack since they aren't gear.

You can however present an illusion of putting items in your backpack by making the unit play an appropriate animation, then making that object invisible and attaching it to the unit (there are many ways to fake this -- this may not be the best way, but it should suffice).

I'll make another example mission for this later today.

Share this post


Link to post
Share on other sites

Ok cheers mate.  I was just using the backpack as an example, tbh what I'd really like to do is as I briefly mentioned above is to load an object using ACE logistics into a vehicle, then unload it in the trigger zone.  But it seems that it looses the variable name doing this.

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

×