Page MenuHomeFeedback Tracker

SetPosition does not work with transport class
Assigned, UrgentPublic

Description

In version 1.8 SetPosition does not work for the transport class, for all other types it works.

// create a global variable
Object m_SpawnedObject = NULL;

1.create transport
vector posSpawn = Vector(1161.617432, 6.139075, 2399.965820);
m_SpawnedObject = GetGame().CreateObjectEx( "OffroadHatchback", posSpawn, ECE_PLACE_ON_SURFACE );
EntityAI MyCar = EntityAI.Cast(m_SpawnedObject);
if (MyCar)
{
MyCar.GetInventory().CreateAttachment("HatchbackWheel");
MyCar.GetInventory().CreateAttachment("HatchbackWheel");
MyCar.GetInventory().CreateAttachment("HatchbackWheel");
MyCar.GetInventory().CreateAttachment("HatchbackWheel");
MyCar.GetInventory().CreateAttachment("HatchbackDoors_Driver");
MyCar.GetInventory().CreateAttachment("HatchbackDoors_CoDriver");
MyCar.GetInventory().CreateAttachment("HatchbackHood");
MyCar.GetInventory().CreateAttachment("HatchbackTrunk");
MyCar.GetInventory().CreateAttachment("SparkPlug");
MyCar.GetInventory().CreateAttachment("SparkPlug");
MyCar.GetInventory().CreateAttachment("EngineBelt");
MyCar.GetInventory().CreateAttachment("CarBattery");
MyCar.GetInventory().CreateAttachment("CarRadiator");
MyCar.GetInventory().CreateAttachment("HeadlightH7");
MyCar.GetInventory().CreateAttachment("HeadlightH7");
MyCar.GetInventory().CreateInInventory("TireRepairKit");
MyCar.GetInventory().CreateInInventory("TireRepairKit");
vector PosTP1 = Vector(5000,0,5000);
PosTP1[1] = GetGame().SurfaceY(PosTP1[0],PosTP1[2]);
MyCar.SetPosition(PosTP1);
no teleportation
}

  1. we execute setpos separately from the spawn

if (m_SpawnedObject)
{
vector PosTP1 = Vector(5000,0,5000);
PosTP1[1] = GetGame().SurfaceY(PosTP1[0],PosTP1[2]);
m_SpawnedObject.SetPosition(PosTP1); // no teleportation
}

Details

Severity
None
Resolution
Open
Reproducibility
N/A
Operating System
Windows 7
Category
General

Event Timeline

komer created this task.Aug 13 2020, 1:26 PM
Geez changed the task status from New to Assigned.Aug 17 2020, 11:19 AM
komer added a comment.Sep 17 2020, 9:41 AM
//Working version of how to teleport transport now

// create transport
 vector posSpawn = Vector (3704.247559, 402.012482, 5985.216309);
 posSpawn [1] = GetGame (). SurfaceY (posSpawn [0], posSpawn [2]);
 MyCar = GetGame () object. CreateObjectEx ("OffroadHatchback", posSpawn, ECE_NONE);
 
 // the code below can be executed at any time, only the agent and coordinates need to be passed
 // disable physics
 dBodyActive (myCar, ActiveState.INACTIVE);
 dBodyDynamic (myCar, false);
 
 // do teleportation to the coordinates we need
 vector NewPos = Vector (5000,0,5000);
 NewPos [1] = GetGame (). SurfaceY (NewPos [0], NewPos [2]);
 myCar.SetPosition (NewPos);
 
 // enable physics
 dBodyActive (myCar, ActiveState.ACTIVE); // you can ACTIVE or ALWAYS_ACTIVE did not notice the difference
 dBodyDynamic (myCar, true);
hlynge added a subscriber: hlynge.Sep 29 2020, 5:56 PM

Hi Komer - regarding your Bot work I would really appreciate if you contact me on discord: hlynge#2885