Help with your scripting

Move around and keep rotation

Move around and keep rotation

Postby SpiderMack » 10 Oct 2017, 09:19

Hi,

How to get a character move some any destinations, but keeping it facing the player ?


If i use :
Code: Select all
entity.yaw(obj, yawDeg, 0);

and
Code: Select all
character.move(obj, moveMaxSpeed );


It's not possible, because it follows the direction you give to it by turning the object to that direction.
User avatar
SpiderMack
Skyline Expert
 
Posts: 441
Joined: 02 Dec 2016, 09:15
Skill: Concept artist
Skill: 3D Modeller
Skill: Level Designer
Skill: Scripter

Re: Move around and keep rotation

Postby SolarPortal » 10 Oct 2017, 13:01

Wouldn't it make the animations look like they are sliding.. perhaps a quick example of what your trying to achieve?
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: Move around and keep rotation

Postby SpiderMack » 10 Oct 2017, 15:44

The character is strafing while keeping orientation to the player.



I think it can be done using SetPosition or Physics with SetVelocity, and code it ourselves.

But for Character system, it needs to have Move() function not depending on character orientation, these are two different systems.
Perhaps Skyline Character will have such new function.
User avatar
SpiderMack
Skyline Expert
 
Posts: 441
Joined: 02 Dec 2016, 09:15
Skill: Concept artist
Skill: 3D Modeller
Skill: Level Designer
Skill: Scripter

Re: Move around and keep rotation

Postby SolarPortal » 10 Oct 2017, 16:24

There are several ways you can do this as move is just so a simple character can be scripted in minutes without any advanced math etc... That move function has accompanying functions in both the controller.library() and character.library() to handle strafing and jumping; seen as follows:

Code: Select all
-- controller library -- dynamic spawned controllers
controller.doStrafe(dccID, speed); -- move left or right depending on minus or positive numbers.
controller.doJump(obj, force);
controller.moveUp(dccID, speed); -- Move up or down based on minus  or positive numbers
--character library
character.doStrafe(obj, speed); -- move left or right depending on minus or positive numbers.
character.doJump(obj, force);
character.moveUp(obj, speed); -- Move up or down based on minus  or positive numbers


but if you want to override this and do the kinematic bodies movement manually, then you can do this.

Code: Select all
-- controller code - dynamically spawned controllers
function postInit()
   controller.setMoveAdvanced(dccID, 1) -- 1 = true(advanced), 0 = false
end

function onUpdate(td)
    controller.setMoveDirection(dccID, dirX, dirY, dirZ);
    controller.move(dccID, speed); -- call move to make the new movement direction happen.
end

-- character code - SCC Action
function postInit()
   character.setMoveAdvanced(obj, 1) -- 1 = true(advanced), 0 = false
end

function onUpdate(td)
    character.setMoveDirection(obj, dirX, dirY, dirZ);
    character.move(obj, speed); -- call move to make the new movement direction happen. Negative numbers will make it go backwards.
end


This way, it means you can make the character rotate and look at the player and move the controller in the direction you need.
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer


Return to Lua Scripting

Who is online

Users browsing this forum: No registered users and 7 guests