-
Posts
41 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by DanceTweety
-
-
I can see you are trying to simulate the reality.
thing is if you turn your sails the "boat" will go sideways it's same in RL but there's 1 thing you haven't in calculated witch is friction of water.
in RL friction of water does actually force for boat to go aerodinamically and not sideways.
what you need to do is 2 things
make proper parenting and after sails are turned so the boat slowly turnes in right dirrection.
without proper parrenting you'll be turning both instead of just desiered one.
well I hope I did help enough and that I did understand the problem.
It is not a sailboat but a motorboat I just want it to sail in the direction it is pointing even after I turn it.
But it only does that at small angle after that it goes back wards and I dont know why.
-
I hope is more clear now
-
Hi All,
I made changes to the script but it still does not make a normale circle when I steer it to left or right
And help is welcome. I test it with a box. What I try to do is get the boot to sail in direction of the Y angle:
Script.enabled = true --bool "Enabled" Script.gravity = false --bool "Gravity" Script.movespeed = 5 --Define self.movespeed Script.originPosition = nil --Define self.originPosition Script.currentPosition = nil --Define self.currentPosition Script.oldMass = nil --Define self.oldMass Script.window = Window:GetCurrent() --Define self.window Script.move = Vec3(0,0,0) --Define self.move Script.rotation = "" --Define self.rotation Script.ry = 0 --Define self.ry Script.speed = "" --Define self.speed function Script:Start() self.originPosition = self.entity:GetPosition() --Get position of object self.oldMass = self.entity:GetMass() --Get mass of object if self.entity:GetShadowMode()>0 then self.entity:SetShadowMode(2)--Light.Dynamic end if self.enabled then if self.entity:GetMass() == 0 then --Get mass and check if bigger then 0 Debug:Error("Entity mass must be greater than zero.") end else self.entity:SetMass(0) end self.entity:SetGravityMode(self.gravity) --Set gravity to false self.entity:SetFriction(0,1) --Set Friction self.move = Vec3(0,0,0) --Set self.move to vector end function Script:UpdatePhysics() --Loop to update Physics self.move = Vec3(0,0,0) local movespeed = self.movespeed --Set movespeed to self.movespeed self.rotation = self.entity:GetRotation():ToString() --Set self.rotation and make it a string (else it is userdata and will not work) self.ry = string.sub(self.rotation,11,15) --Set self.ry with y of rotation (if cuts of x and z) self.ry = tonumber(self.ry) --Set self.ry to be a number self.ry = math.ceil(self.ry) --Set self.ry to be a round number if (self.window:KeyDown(Key.Up)) then self.move.x = -1 * movespeed * math.cos(self.ry) * Time:GetSpeed() end --Look if upper arrow key is pressed and Set value in selfmove.x (x-axis) if (self.window:KeyDown(Key.Up)) then self.move.z = -1 * movespeed * math.sin(self.ry) * Time:GetSpeed() end --Look if upper arrow key is pressed and Set value in selfmove.z (z-axis) if (self.window:KeyDown(Key.Down)) then self.move.x = movespeed * math.cos(self.ry) * Time:GetSpeed() end --Look if lower arrow key is pressed and Set value in selfmove.x (x-axis) if (self.window:KeyDown(Key.Down)) then self.move.z = movespeed * math.sin(self.ry) * Time:GetSpeed() end --Look if lower arrow key is pressed and Set value in selfmove.z (z-axis) if (self.window:KeyDown(Key.Right)) then self.move.y= movespeed * Time:GetSpeed() end --Look if right arrow key is pressed and Set value in selfmove.y (y-axis rotation) if (self.window:KeyDown(Key.Left)) then self.move.y= -1 * movespeed * Time:GetSpeed() end --Look if left arrow key is pressed and Set value in selfmove.y (y-axis rotation) self.entity:AddForce(self.move.x,0,0) --AddForce with the self.move.x value on x-axis self.entity:AddForce(0,0,self.move.z) --AddForce with the self.move.z value on z-axis self.entity:AddTorque(0,self.move.y*50,0) --AddTorque with the self.move.y value on y-axis (rotation) Time:Update() --Update Time value end function Script:PostRender() --Function to print on game screen local context=Context:GetCurrent() context:SetBlendMode(Blend.Alpha) --Set blend to alpha so only letters will show context:DrawText("Rotation :".. self.ry .."",5,130) --Set text and position of text --context:DrawText("Speed :".. self.speed .."",5,140) --Set text and position of text end
-
Hi All,
I made changes to the script but it still does not make a normale circle when I steer it to left or right
And help is welcome. I test it with a box. What I try to do is get the boot to sail in direction of the Y angle:
Script.enabled = true --bool "Enabled"
Script.gravity = false --bool "Gravity"
Script.movespeed = 5 --Define self.movespeed
Script.originPosition = nil --Define self.originPosition
Script.currentPosition = nil --Define self.currentPosition
Script.oldMass = nil --Define self.oldMass
Script.window = Window:GetCurrent() --Define self.window
Script.move = Vec3(0,0,0) --Define self.move
Script.rotation = "" --Define self.rotation
Script.ry = 0 --Define self.ry
Script.speed = "" --Define self.speed
function Script:Start()
self.originPosition = self.entity:GetPosition() --Get position of object
self.oldMass = self.entity:GetMass() --Get mass of object
if self.entity:GetShadowMode()>0 then
self.entity:SetShadowMode(2)--Light.Dynamic
end
if self.enabled then
if self.entity:GetMass() == 0 then --Get mass and check if bigger then 0
Debug:Error("Entity mass must be greater than zero.")
end
else
self.entity:SetMass(0)
end
self.entity:SetGravityMode(self.gravity) --Set gravity to false
self.entity:SetFriction(0,1) --Set Friction
self.move = Vec3(0,0,0) --Set self.move to vector
end
function Script:UpdatePhysics() --Loop to update Physics
self.move = Vec3(0,0,0)
local movespeed = self.movespeed --Set movespeed to self.movespeed
self.rotation = self.entity:GetRotation():ToString() --Set self.rotation and make it a string (else it is userdata and will not work)
self.ry = string.sub(self.rotation,11,15) --Set self.ry with y of rotation (if cuts of x and z)
self.ry = tonumber(self.ry) --Set self.ry to be a number
self.ry = math.ceil(self.ry) --Set self.ry to be a round number
if (self.window:KeyDown(Key.Up)) then self.move.x = -1 * movespeed * math.cos(self.ry) * Time:GetSpeed() end --Look if upper arrow key is pressed and Set value in selfmove.x (x-axis)
if (self.window:KeyDown(Key.Up)) then self.move.z = -1 * movespeed * math.sin(self.ry) * Time:GetSpeed() end --Look if upper arrow key is pressed and Set value in selfmove.z (z-axis)
if (self.window:KeyDown(Key.Down)) then self.move.x = movespeed * math.cos(self.ry) * Time:GetSpeed() end --Look if lower arrow key is pressed and Set value in selfmove.x (x-axis)
if (self.window:KeyDown(Key.Down)) then self.move.z = movespeed * math.sin(self.ry) * Time:GetSpeed() end --Look if lower arrow key is pressed and Set value in selfmove.z (z-axis)
if (self.window:KeyDown(Key.Right)) then self.move.y= movespeed * Time:GetSpeed() end --Look if right arrow key is pressed and Set value in selfmove.y (y-axis rotation)
if (self.window:KeyDown(Key.Left)) then self.move.y= -1 * movespeed * Time:GetSpeed() end --Look if left arrow key is pressed and Set value in selfmove.y (y-axis rotation)
self.entity:AddForce(self.move.x,0,0) --AddForce with the self.move.x value on x-axis
self.entity:AddForce(0,0,self.move.z) --AddForce with the self.move.z value on z-axis
self.entity:AddTorque(0,self.move.y*50,0) --AddTorque with the self.move.y value on y-axis (rotation)
Time:Update() --Update Time value
end
function Script:PostRender() --Function to print on game screen
local context=Context:GetCurrent()
context:SetBlendMode(Blend.Alpha) --Set blend to alpha so only letters will show
context:DrawText("Rotation :".. self.ry .."",5,130) --Set text and position of text
--context:DrawText("Speed :".. self.speed .."",5,140) --Set text and position of text
end
-
Ok now I get just set it on BETA and dont enter a password. I had same problem
-
Is not working it still works same as normal add force only it capsizes the boat.
It does not change the forward direction. So you turn like you would using y axis torque but you stay moving in the same direction so boat ends up sailing backward.
-
Ok gona try it out thanks
-
Why not applying a local force or torque on some direction or point of boat to turn ?
I done it already for some Fzero style game test and it works.
How can you apply some force on a local point on the boat instead of the whole boat?
-
Hi all,
I trying to make a script to make a boat sail.
This script works. But to steer it I want to put the script in engine, and put it at the back of the boat(box2 is test box I us to simulate engine) and use a hinge to steer it with y axis.
Problem is the hinge dont seem to work in this script I made:
Script.enabled = true --bool "Enabled"
Script.gravity = false --bool "Gravity"
Script.movespeed = 10
Script.originPosition = nil
Script.currentPosition = nil
Script.oldMass = nil
Script.window = Window:GetCurrent()
Script.move = Vec3(0,0,0)
Script.Parent = boat
function Script:Start()
self.originPosition = self.entity:GetPosition()
self.oldMass = self.entity:GetMass()
if self.entity:GetShadowMode()>0 then
self.entity:SetShadowMode(2)--Light.Dynamic
end
if self.enabled then
if self.entity:GetMass() == 0 then
Debug:Error("Entity mass must be greater than zero.")
end
else
self.entity:SetMass(0)
end
self.entity:SetGravityMode(self.gravity)
self.entity:SetFriction(0,1)
self.move = Vec3(0,0,0)
self.parent = Model:Box(self.Parent)
self.child = Model:Box(self.entity)
self.joint = Joint:Hinge(0,10,0, 0,0,1, self.child, self.parent)
self.joint:SetLimits(-45,45)
self.joint:EnableLimits()
end
function Script:UpdatePhysics()
self.move = Vec3(0,0,0)
local movespeed = self.movespeed
if (self.window:KeyDown(Key.Down)) then self.move.x= movespeed * Time:GetSpeed() end
if (self.window:KeyDown(Key.Up)) then self.move.x= -1 * movespeed * Time:GetSpeed() end
if (self.window:KeyDown(Key.Right)) then self.move.y= movespeed * Time:GetSpeed() end
if (self.window:KeyDown(Key.Left)) then self.move.y= -1 * movespeed * Time:GetSpeed() end
self.entity:AddForce(self.move.x,0,self.move.z)
self.entity:AddTorque(0,self.move.y,0)
Time:Update()
end
Does someone have some tips?
-
I have same soon as I step in to collision box I crash.
-
Sound great!!!
-
I hope there will be at least some good ocean water and a Reflect shader for us of cubemaps that you can tell how refletive it should be.
-
Leadwerks has almost the same one, but the tabs are on the left
I dont see it in leadwerks 3.1 where is it?
Script to make boat sail
in Programming
Posted
If I us pointforce it still will not get the boat to sail in the direction it is pointing and it makes the boat sink I tryed that.
And what do you mean with "make proper parenting". I dont have a sail or a motor. I am testing with a box.