Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Possible bug? Or is there a reason for this?

Asked by 4 months ago
Edited 4 months ago

Exactly as it is here this code works, but if I take out the color property in the matrix (line 23) or reverse the orientation and color lines, the orientation fails to set and resets to default.

Why?!

local TweenService = game:GetService("TweenService")
local wallgroup = script.Parent
local tweeningInformation = TweenInfo.new(  
    3,
    Enum.EasingStyle.Sine,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)

local centrepoint = 0
local wallsize = 20 
local wallnumber = 1
xposition = centrepoint +(wallsize*wallnumber)
wallgroup.Position = Vector3.new(xposition,yposition,zposition)

while true do
    for i=1,6,1 do
        xposition = xposition + wallsize
        local wallgroupfinish = {
            CFrame = CFrame.new(xposition,0,0);
            Color = Color3.fromRGB(255,0,0);
            Orientation = Vector3.new(90,90,90)
        }
        local tweenmove = TweenService:Create(wallgroup,tweeningInformation,wallgroupfinish)
        tweenmove:Play()
        wait (4)
    end
    xposition = centrepoint +(wallsize*wallnumber)
    wallgroup.Position = Vector3.new(xposition,yposition,zposition)
end
0
Okay I'm sorta confused, please explain with more detail, like what do you mean by orientation, and the matrix and taking the out color property? Thanks, TheOnlySmarts. TheOnlySmarts 162 — 4mo
0
In the future give more description on what the problem is, what you've tried, and what you're expecting. SinisterMemories 754 — 4mo
0
I was trying to apply a tween that changes both the location and orientation of a part. However, the orientation would only set when there was an extra line (the colour property) between the position CFrame and orientation Vector3. Likely_Lad 4 — 4mo

1 answer

Log in to vote
0
Answered by 4 months ago
Edited 4 months ago

psss, accept this answer if it helps (ok you can read the answer now)

Problem

the orientation fails to set and resets to default.

Whats wrong

I would assume its because you're also setting the CFrame. Remember CFrame is a matrix that contains a position, as well rotation. You're giving a default 0, 0, 0 orientation in the CFrame so it will keep setting it to that.

Solution

Multiply the CFrame by a rotation matrix CFrame.Angles(...) and remove Orientation = Vector3.new(90,90,90) from the tween properties table.

local rot = math.pi / 2 --// 90 degrees

local wallgroupfinish = {
    CFrame = CFrame.new(xposition, 0, 0) * CFrame.Angles(rot, rot, rot) --// apply cframe with position and rotation,
    Color = Color3.new(1, 0, 0) --// set color to bright red (255, 0, 0)
}

Also we are using math.pi / 2 since pi / 2 radians in 90 degrees. CFrame.Angles takes radians not degrees but if you want to use degrees you can use math.rad(x) and pass that. Also I'm setting a variable rot so we can cut down on the amount of operations the lua VM has to process and i'm using Color3.new since you're setting the color to an absolute value of 255 for red.

0
I tried to CFrame matrix and it worked (although for some reason had to use rot*2 to get the same rotation as with Vector3 - suppose the systems work differently. I'll study this!). Actually I thought there was a system like this but couldn't find a demonstration that I understood on the wiki. Thanks for your answer. Likely_Lad 4 — 4mo
0
angles takes radians not degrees incapaxx 3270 — 4mo
0
oops that is what I meant. Thank you incapaxx SinisterMemories 754 — 4mo
Ad

Answer this question