Jump to content

SetPosition wont work on controllers?


Soamp
 Share

Recommended Posts

Hi,

I've a problem with controller. I have a character who can walk around freely and drive a car with sending a "use" message.

I hide it's model and controller when it's driving a car but it appears in it's old position (where it got on the car) when it get off the car.

I used SetPosition on controller and set it's position to my car pivot position when it get off the car but the controller wont move!

 

object.controller:SetPosition(carpivot:GetPosition(1),1)

 

When I use UpdateController instead of SetPosition, the controller moves from it's original position but it's too difficult to use UpdateController to move the controller exactly wherever I want.

 

self.controller:Update(EntityRotation(carpivot,1).y,CARSPEED.z,0, 0, 5000, 10)

 

BTW. I'm using PiCharacter but I made some changes on it's sourcecode.

 

I have a couple of questions :

Did anyone work on getting on/off vehicles?

Is there any way to use SetPosition correctly on controllers? Am I doing somthing wrong?

 

thanks

Link to comment
Share on other sites

I would just walk the controller inside the car, and have somekind of arresting mechanism to hold the controller in place. For example put some invisible physics cubes around the controller when he is inside the car, so he will move when the car moves.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Does the character require a controller when in the car? I wouldn't think it would, so I would just hide the controller (if that's possible) when the character gets in and unhide it when it gets out. Generally when your character gets into a vehicle the vehicle now becomes the controller.

Link to comment
Share on other sites

here is what I've done:

my character is for example in (10,10,10) behind the car:

01.jpg

by pressing "E" he will get in the car and mesh and controller will be just invisible.

I can drive to a new position like (100,100,100):

02.jpg

in 100,100,100 I want to get out of the car. so I set character controller position to 100,100,100.

but it will appear in 10,10,10:

03.jpg

do you know why?! :)

 

here is my script:

Pi_Character.lua

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...