generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: I can't find the error in my thinking

Previous Thread :: Next Thread 
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
24 Apr 2017 02:09 AM
I'm attempting to "constrain" parts with BodyPosition. It's working better than actual constraints were for me.

I'm basically making a hover car.
The Vehicle's PrimaryPart's BodyPosition (named vehicleHover) is set to 8 studs above ground level, plus math.sin(tick()) for a hovering effect.

The Fan's BodyPosition (fanHover) and the Turret's BodyPosition (turretHover) need to be the PrimaryPart's destination plus an offset.
I did this by looping the following. I can loop very infrequently, because of the dampening effect of BodyMovers (yay!)

local hoverPos = Vector3.new(vehicle.PrimaryPart.Position.X+5,pos.Y+8+math.sin(tick()),vehicle.PrimaryPart.Position.Z+5)

vehicleHover.Position = hoverPos
fanHover.Position = (CFrame.new(hoverPos,vehicle.PrimaryPart.Rotation)*CFrame.new(0,2.5,-6)).p
turretHover.Position = (CFrame.new(hoverPos,vehicle.PrimaryPart.Rotation)*CFrame.new(-0.2, 4, 0.22)).p


-- This is the undedesired effect that is being produced... (qyazo)
/f1b1c06991f29f8866d08a9d9940e4d2

My offset is somehow incorrect, and I'm not sure what I'm doing wrong.


Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
24 Apr 2017 02:10 AM
undesired*


Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
24 Apr 2017 02:15 AM
I assume these are the points of error:

CFrame.new(hoverPos,vehicle.PrimaryPart.Rotation)
specifically the 2nd argument


Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
24 Apr 2017 02:43 AM
And I _especially_ don't understand this one...

/3c4bbad610003b48714f8eb85f583271

local hoverPos = Vector3.new(vehicle.PrimaryPart.Position.X+5,pos.Y+8+math.sin(tick()),vehicle.PrimaryPart.Position.Z+5)

vehicleHover.Position = hoverPos
fanHover.Position = (vehicle.PrimaryPart.CFrame*CFrame.new(0,2.5,6)).p
turretHover.Position = (vehicle.PrimaryPart.CFrame*CFrame.new(-0.2, 4, 0.22)).p

-- ^ how could this possible go wrong? I mean, it's not ideal because the turret and fan will lag behind the main vehicle body, but they should at least be properly offset..? Apparently not


Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Apr 2017 03:41 AM
The CFrame.new(Vector3 a, Vector3 b) constructor constructs a CFrame at point a and makes it "look at" b. When you set it to face the rotation you end up making it face near the origin of the map (some weird rectangle between (-18 0, -1 80, -1 80), (18 0, 1 80, 1 80))
Instead what you want to do is something like

fanHover.Position = hoverPos + primarypart.CFrame:vectorToWorldSpace(Vector3.new(0.2.5,-6))
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Apr 2017 03:42 AM
(Referring to: "CFrame.new(hoverPos,vehicle.PrimaryPart.Rotation)")
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
24 Apr 2017 12:23 PM
Thank you, that appears to be working, but out of curiosity, why didn't the 2nd work?


Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
24 Apr 2017 12:24 PM
That is,
fanHover.Position = (vehicle.PrimaryPart.CFrame*CFrame.new(0,2.5,6)).p


Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Apr 2017 02:38 PM
You probably wanted -6
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image