Jump to content

Physics related questions and problems.


Alienhead
 Share

Recommended Posts

I'm workind with a smaller scale than the normal character controller initializes at.  Being so, all my collisions are off, meaning I interact with objects well before I should be due to the fact my character scale is smaller than the normal.  I don't suppose theres a way to adjust character controller bounding box? or perhaps a custom shape ?

I'm only happy when I'm coding, I'm only coding when I'm happy.

Link to comment
Share on other sites

Next question is, "whats the current state of createhingejoint?".

I'll borrow some code from UAGC to demonstrate.

    self.entity:AddTag("UAGC:Rope")
    self.entity:Move(0,.5,0)
    self.base = self.entity
    self.child = {}
    self.joint = {}
    self.box = {}
    self.knot = {}
    self.tmr = Millisecs() + 100
    table.insert ( uRope, {ent = self.enttiy})
    local last


    for t=1, self.segs do

        self.child[t] = CreateCylinder(world)
        self.box[t] = CreateBoxBrush(world)
        self.box[t]:SetCollisionType(0)
        self.box[t]:SetScale(.1, self.height, .1)

        self.child[t]:SetScale(self.width, self.height, self.width)
        self.child[t]:SetColor(1, 1, 1)
        self.child[t]:SetPosition(self.entity:GetPosition())
        self.child[t]:Move(0,-self.dist*t,0)
        local mass = 2
        self.child[t]:SetMass(mass)
        self.child[t]:SetColor(.5,.5,.5)

        self.knot[t] = CreateSphere(world)
        self.knot[t]:SetScale(self.width*3,self.width*3,self.width*3)
        self.knot[t]:SetScale(.01,.01,.01)
        self.knot[t]:SetCollisionType(0)
        self.knot[t]:SetPosition(self.child[t]:GetPosition(true))
        self.knot[t]:Move(0,-self.height/2, 0 )
        self.knot[t]:SetParent(self.child[t], true)
        self.knot[t]:SetColor(.5,.5,.5)

        self.box[t]:SetPosition(self.child[t]:GetPosition(true))
        self.box[t]:SetParent(self.child[t], true)
        self.box[t]:SetHidden(true)

        if t == 1 then
            --self.joint[t] = CreateHingeJoint(self.base.position, Vec3(1, 1, 1), self.base, self.child[t])
            self.joint[t] = CreateBallAndSocketJoint(self.base.position, self.base, self.child[t])
        else
            --self.joint[t] = CreateHingeJoint(last.position, Vec3(0, 2, 0), last, self.child[t])
            local apos = Vec3(last:GetPosition().x, last:GetPosition().y- (self.height/2), last:GetPosition().z)
            self.joint[t] = CreateBallAndSocketJoint(apos, last, self.child[t])
        end
        --self.joint[t]:SetFriction(111250)
        self.joint[t]:SetLimits(15,360)
        --self.joint[t]:SetLimits(-1000,90)
        self.child[t]:SetPickMode(0)
        self.box[t]:SetPickMode(0)
        self.knot[t]:SetPickMode(0)

        last = self.child[t]

    end

    self.bulb = LoadModel(world,"models/misc/bulb/lightbulb.mdl")
    self.bulb:SetPosition(last.position)
    self.bulb:Move(0,-self.height/2, 0 )
    local apos = Vec3(last:GetPosition().x, last:GetPosition().y- (self.height/2), last:GetPosition().z)
    CreateHingeJoint(apos, Vec3(0, 0, 1), last, self.bulb)


end

This code creates a rope, jointed together. That all works great. When I go to attack an object to the end of the rope it falls immediately off.  Shouldnt CreateHingeJoint() hold the object in place since im attaching it to a parent ?

PS The code above does not add a mass to the bulb, but I've corrected that and still the same results.

 

 

I'm only happy when I'm coding, I'm only coding when I'm happy.

Link to comment
Share on other sites

Last problem - 

 

  1. A bit of a problem, I have this table mesh with a collider attached to it.
     
  2. Image
    But I get no collisions, my character controller falls to the terrain as well as anything else sitting on the table. Why wont this object pickup collision ?

 

I'm only happy when I'm coding, I'm only coding when I'm happy.

Link to comment
Share on other sites

  • Alienhead changed the title to Physics related questions and problems.

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...