+ Reply to Thread
Results 1 to 3 of 3

Thread: Need some help on orienting the expression by the current position of my hand bone.

  1. #1
    Lurker Proximis is on a distinguished road Proximis's Avatar
    Join Date
    Jul 2009
    Posts
    1

    Default Need some help on orienting the expression by the current position of my hand bone.

    Here is my code,

    Code:
    @name Righ hand orientation
    @inputs 
    @outputs 
    @persist Vector:vector A P Y R
    interval(2)
    A+=(0.1 * 150)
    Vector=owner():attachmentPos("anim_attachment_RH")-(entity():pos()-vec(0,0,20))
    applyForce($Vector*15+Vector)
    entity():setMass(1)
    E=entity()
    Dir = E:owner():right():toAngle()
    P = angnorm(Dir:pitch() - E:angles():pitch())
    Y = angnorm(Dir:yaw() - E:angles():yaw())
    R = angnorm(Dir:roll() - E:angles():roll())
    E:applyAngForce(ang(P+$P,Y+$Y,R+$R)*2)
    E:isWeldedTo():setMass(0.01)
    
    This is, a rather hacky but working script for allowing me to carry things like suitcases, but I hate how bad it looks when I take out a gun or anything, because it just stays in the same place, it only turns when I turn sideways.

    Anyone out there who can help me with this?

    EDIT: Before I forget, its E2 not E1.

    Also, if anyone can take a look at my follower code, both are based on the same code because it seemed less time consuming to edit the hand code to make a follower...

    Code:
    @name Follower
    @inputs 
    @outputs 
    @persist Vector:vector A P Y R
    interval(2)
    A+=(0.1 * 150)
    Vector=owner():attachmentPos("anim_attachment_head")-(entity():pos()-vec(0,0,20))
    applyForce($Vector*15+Vector)
    entity():setMass(1)
    E=entity()
    ENT=entity:pos()
    OWN=owner:pos()
    Dir = E:owner():forward():toAngle()
    P = angnorm(Dir:pitch() - E:angles():pitch())
    Y = angnorm(Dir:yaw() - E:angles():yaw())
    R = angnorm(Dir:roll() - E:angles():roll())
    E:applyAngForce(ang(P+$P,Y+$Y,R+$R)*2)
    E:isWeldedTo():setMass(0.01)
    if (ENT-OWN>120) {applyForce(entity():pos())
    

    Seems to break on the last line...
    Last edited by Proximis; 07-04-2009 at 03:45 AM.

  2. #2
    Lurker eurocracy is on a distinguished road eurocracy's Avatar
    Join Date
    Sep 2007
    Posts
    117

    Default Re: Need some help on orienting the expression by the current position of my hand bon

    Hmm, I don't see any way around this except for using if statements to determine which weapon and use trig to determine where it will be around the body. Good luck
    My sig was 201 pixels long so moderators snipped it
    Oh teh noes!

  3. #3
    Lurker Undomian is on a distinguished road Undomian's Avatar
    Join Date
    Nov 2008
    Posts
    87

    Default Re: Need some help on orienting the expression by the current position of my hand bon

    It "breaks" on the last line because you're feeding a position vector to the applyForce() function as opposed to a direction vector. Try replacing that with something like:

    e2 Code:
    1. applyForce(owner():pos() - entity():pos())
    Last edited by Undomian; 07-04-2009 at 10:39 PM. Reason: Damn emoticon.

+ Reply to Thread

Similar Threads

  1. Syntax of Bone and Bone names.
    By no_one in forum Expression 1 & 2
    Replies: 8
    Last Post: 06-01-2009, 03:06 AM
  2. [E2] Bone Question
    By Nicolai1 in forum Technical Support
    Replies: 4
    Last Post: 05-31-2009, 02:30 AM
  3. Letting a plate(E2) hover at it's current position.
    By vortexnl in forum Expression 1 & 2
    Replies: 14
    Last Post: 05-08-2009, 03:20 PM
  4. How to get the current Z position of a player?
    By Beer in forum Technical Support
    Replies: 4
    Last Post: 07-25-2007, 12:04 PM
  5. Wire hand v1
    By Peanutzero in forum Finished contraptions
    Replies: 6
    Last Post: 07-14-2007, 04:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots