Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
when i turn the cam the player done not turn i said to my self maybe be if i right cilck it will work and it didnt pls help any help i will take. thank you. |
||||
|
Can you explain a little more please? The 3rd person cameras usually follow the player. You can make the player follow a 3rd person cam (if that's what you're trying to do?) - with or without coding. |
||||
|
i need the player to follow the cam like wwz or something |
||||
|
can you help with that? |
||||
|
hello? |
||||
|
There are a few plugins that allow one node to follow another. Probably the easiest in this case is the "Move AI towards node" plugin. To do this, just add a game behaviour to the camera and the player nodes and set the "move AI towards node" on the player node to move towards the camera node every few milliseconds..... /* <action jsname="action_MoveAIM" description="Move AI in direction of a Node"> <property name="TargetNode" type="scenenode" /> <property name="AOffset" type="float" default="5." /> </action> */ action_MoveAIM = function() {}; action_MoveAIM.prototype.execute = function(currentNode) { var position = ccbGetSceneNodeProperty(currentNode, "Position"); var newpos = ccbGetSceneNodeProperty(this.TargetNode, "Position"); ccbAICommand(currentNode, "moveto", newpos); var moveto = (newpos); var mvec = moveto.substract(position); mvec.normalize(); mvec.x=Math.round(mvec.x*this.AOffset); mvec.y=Math.round(mvec.y*this.AOffset); mvec.z=Math.round(mvec.z*this.AOffset); ccbAICommand(currentNode, "moveto", moveto.add(mvec)); } /* Action created by: Dude */ |
||||
|
...another alternative would be the "follow" plugin combined with "rotate one object towards another object" from just_in_case's neophytes website. Set the follow plugin on the player node to "follow the camera" edit the plugin to change the camera distance from the node it is following.... /* <behavior jsname="behavior_follow" description="Follow"> <property name="NodeToFollow" type="scenenode" /> </behavior> */ behavior_follow = function(){ } behavior_follow.prototype.onAnimate = function(currentNode){ var curPos=ccbGetSceneNodeProperty(this.NodeToFollow,"Position"); ccbSetSceneNodeProperty(currentNode,"Position",curPos.x+0,curPos.y+0,curPos.z+0); } |
||||
|
...and finally, you could use "follows me" plugin (I think you need to add "game character" behaviours on both nodes again, for the AI to work)..... /* <behavior jsname="behavior_Follow_Me" description="Follows Me"> <property name="WhoFollows" type="scenenode" default="" /> <property name="Delay" type="int" default="50" /> </behavior> */ behavior_Follow_Me = function() { this.Occurring_Time = 1; }; behavior_Follow_Me.prototype.onAnimate = function(currentNode) { // Interval Occurring: if (this.Occurring_Time > this.Delay) { // Follows SceneNode: this.Occurring_Time = 1; ccbAICommand(currentNode, "moveto", new ccbGetSceneNodeProperty(this.WhoFollows, "Position")); } this.Occurring_Time += 1; return true; } |
||||
|
Thank you so much for this, but how do i make it or get the plugin? |
||||
|
to use the extensions VP posted you need to save the script with the same name as jsname for example for this script below you need to save it in documents/coppercube/extensions/ as behavior_follow.js /* |
||||
|
@edwin123 There is an option in the SM thirdperson camera afaik that allows to turn on the rotation with mouse on and off or control the player rotation with the arrow keys. I think that's what you are facing that your player is not turning when you rotate the camera with the mouse. Your camera look direction changes but your player still looks in its original direction and doesn't turn towards the camera target. Let me know if this is the case with you. As I personally didn't used the extension in any of my project, I don't remember the options that much, but I beleive there are options in the @Saman's TPP controller to do that. |
||||
|
i got it to work Thank you! ![]() |
|