Allaric Posted December 8, 2014 Share Posted December 8, 2014 Hello all, I am having trouble positioning and moving an instanced entity. Basically, I am trying to instance a snowball in front of my creature and have him throw that snowball at the target. When I instance the object, I can force the position, but I don't know how to calculate the position relative to the player facing. I also do not know how to calculate and apply the correct the velocity vector to be applied in order for the snowball to be thrown. As part of this, I would also like to be able to adjust this trajectory during the physics update in case I need to track a target. I do not want to use the Nav Mesh related commands of move or follow as I do not want the snowball to be bound to only navigable terrain. I have scoured the forums and reviewed the Project Saturn tutorials for a few days now, but I haven't been able to find a solution. I would GREATLY appreciate any help you can provide. I thought the Transform command might be the right idea, but it didn't react the way I expected. Example Code: local Snowball = nil --entity local Snowball_Model = nil-- entity local Origin = Vec3(0,0,0) self.Snowball_Model = Prefab:Load("Prefabs/Weapons/Snowball.pfb") self.Origin = Thrower:GetPosition(true) self.Snowball = self.Snowball_Model:Instance() self.Snowball:SetPosition(self.Origin.x + 1, self.Origin.y +1, self.Origin.z + 1) --self.Snowball:SetPosition(Transform:Point(1,1,1,self.Origin, nil) --Tried this but it placed --the snowball far away from the model. self.Snowball:Point(self.Target) Thanks in advance, Allaric Quote Link to comment Share on other sites More sharing options...
macklebee Posted December 8, 2014 Share Posted December 8, 2014 here is an example from LE2 - the concept would be the same but syntax would be slightly different for LE3 Transform commands: http://www.leadwerks.com/werkspace/topic/2542-bullet-help-wanted/#entry23432 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Allaric Posted December 9, 2014 Author Share Posted December 9, 2014 Thank you Macklebee! I was able to use the example and noodle through spawning and tossing the snowball! I had to use SetVelocity() on the UpdatePhysics in order to track the target instead of just adjusting the flight path (AddForce made it hit warp speed for obvious reasons). It would be cool if I could just adjust the velocity to allow tracking and leave an arc from an initial AddForce Y value, but it works. I do have an issue with the target entity since I am using Point(). With the pivot on the floor I hit everyone's feet, and with Point() it doesn't seem like there is a way to just add +1 Y value to the axis. I saw in the tutorial that a suggestion was to create a target Pivot and attach it to the character models, but I was wondering if there was a way to just add a little height instead of creating additional entities. Thanks again for your help thus far. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.