Jump to content

Recommended Posts

Posted

Has anyone gotten the Point function to work with a character controller? I have the following call that gets hit once (flags prevent it from getting hit after that) and it doesn't rotate at all.

 

-- where this script is attached to a character model that has the character controller set for it

self.entity:Point(self.pointAtEntity, 1, 500)

Posted

character controllers need to use setinput to rotate.

 

see thread here

bool Life()
{
 while(death=false)
 {
   if(death==true)
   return death;
 }
}

 

I have found the secret to infinite life

 

Did I help you out? Like my post!

Posted

You can use Math::ATan2 to figure out the correct angle from the difference between the two entity positions.

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

I have the following attached to the character but it doesn't work.

 

the pos parameter is the entity to point at

 

function Script:FaceEntity(pos2)
local pos1 = self.entity:GetPosition(true)
local v = Vec2()

v.y = pos1.x - pos2.x
v.x = pos1.z - pos2.z

local angle = Math:ATan2(v.y, v.x)
self.entity:SetRotation(0, angle, 0)
end

Posted

Dammnit I don't want to use SetInput smile.png

 

This still didn't seem to work when I changed it to:

 

function Script:FaceEntity(pos2)
local pos1 = self.entity:GetPosition(true)
local v = Vec2()

v.y = pos1.x - pos2.x
v.x = pos1.z - pos2.z

local angle = Math:ATan2(v.y, v.x)
self.entity:SetInput(angle, 0)
end

 

Note that my game is a point and click so I don't call SetInput() like in a fps or third person game moving with the keyboard. It's all GoToPoint() driven.

Posted

I thought you hated point-n-clicks? huh.png

 

In any case, what about it doesn't work? Is it not returning the right angle? And wouldn't you still have to use SetInput() to move your character to the 'GoToPoint'?

 

In LE2, I used essentially the same setup:

function PerfectAngle(pos1,pos2)
  local dx, dz
  dx = pos1.x - pos2.x
  dz = pos1.z - pos2.z
  return math.deg(math.atan2(-dx,dz))
end
...

perfectangle = PerfectAngle(gotohere,player.position)
angle=IncAngle(perfectangle,angle,5/AppSpeed())
...
...
player:Update(angle,move,0,0,500,1,0)

  • Upvote 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Posted

And wouldn't you still have to use SetInput() to move your character to the 'GoToPoint'?

 

Nope. GoToPoint() is magic smile.png

 

Had some code structure issues but it's "working". Right now he points in the complete opposite direction. Getting closer.

 

 

[edit]

Got it. Thanks for the code mac.

Posted

Nope. GoToPoint() is magic smile.png

Had some code structure issues but it's "working". Right now he points in the complete opposite direction. Getting closer.

yeah i dont use that... it feels dirty.. like cheating... wink.png

 

well without seeing all of your code or character setup i can only guess, but if you notice i am using a 'negative' value when calculating ATan2

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

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.

×
×
  • Create New...