Novo grupo
Ir à página Anterior  1, 2, 3, 4  Próximo
 
   3D Game Builder - Índice » Geral
Novo grupo
Autor Mensagem
Sergio Sinistro
Usuário
Usuário


Registrado: 25/03/12
Mensagens: 263
Localização: Amazonas

cara qual a configuração do seu pc?

o meu pc é um lixo roda tudo com lag e quando eu falei que roda o crysis eu quis dizer ah... bem... digamos...

roda...

com resolução 800x900 e tudo no low e off!

Meu pc: escreveu:

Processador: Intel Core 2 Quad Q8400 2.66Ghz
Memoria RAM: 4GB (DDR2)
HD: 500GB
Placa de vídeo: Geforce 9500GT 1GB (DDR2)
Sistema operacional: Windows XP SP3



Qui Jun 28, 2012 6:09 pm Exibir perfil de usuários
leocgamer
Usuário
Usuário


Registrado: 27/06/12
Mensagens: 92

Câmera, Controle do Personagem (FPS), Javascript (Unity)
Sim "Sérgio Sinistro", para movimentar o personagem é tudo isso que você disse, porém não é difícil, o negócio é ter paciência e saber programar, em Javascript (UNITY), Csharp ou Boo, você que escolhe o tipo de linguagem que você vai usar. Exemplos de código.:

CÂMERA SEGUE PERSONAGEM:

Citação:
//Esse script foi criado pela Unity Technologies com o nome "SpringFollowCamera" e incluido em demo gratuita.
//Deve ser "grudado" na MainCamera e, o avatar deve ser arrastado para a veriável Target, no Inspector.
//As variáveis Distance e Height devem ser definidas melhor. 10 e 3 são um palpite.Testar.
//Usar com ControladorDoAvatar.js

// This camera is similar to the one used in Jak & Dexter

var target : Transform;
var distance = 4.0;
var height = 1.0;
var smoothLag = 0.2;
var maxSpeed = 10.0;
var snapLag = 0.3;
var clampHeadPositionScreenSpace = 0.75;
var lineOfSightMask : LayerMask = 0;

private var isSnapping = false;
private var headOffset = Vector3.zero;
private var centerOffset = Vector3.zero;
private var controller : ControladorDoAvatar;
private var velocity = Vector3.zero;
private var targetHeight = 100000.0;

function Awake ()
{
var characterController : CharacterController = target.collider;
if (characterController)
{
centerOffset = characterController.bounds.center - target.position;
headOffset = centerOffset;
headOffset.y = characterController.bounds.max.y - target.position.y;
}

if (target)
{
controller = target.GetComponent(ControladorDoAvatar);
}

if (!controller)
Debug.Log("Please assign a target to the camera that has a Third Person Controller script component.");
}

function LateUpdate () {

var targetCenter = target.position + centerOffset;
var targetHead = target.position + headOffset;

// When jumping don't move camera upwards but only down!
if (controller.IsJumping ())
{
// We'd be moving the camera upwards, do that only if it's really high
var newTargetHeight = targetCenter.y + height;
if (newTargetHeight < targetHeight || newTargetHeight - targetHeight > 5)
targetHeight = targetCenter.y + height;
}
// When walking always update the target height
else
{
targetHeight = targetCenter.y + height;
}

// We start snapping when user pressed Fire2!
if (Input.GetButton("Fire2") && !isSnapping)
{
velocity = Vector3.zero;
isSnapping = true;
}

if (isSnapping)
{
ApplySnapping (targetCenter);
}
else
{
ApplyPositionDamping (Vector3(targetCenter.x, targetHeight, targetCenter.z));
}

SetUpRotation(targetCenter, targetHead);
}

function ApplySnapping (targetCenter : Vector3)
{
var position = transform.position;
var offset = position - targetCenter;
offset.y = 0;
var currentDistance = offset.magnitude;

var targetAngle = target.eulerAngles.y;
var currentAngle = transform.eulerAngles.y;

currentAngle = Mathf.SmoothDampAngle(currentAngle, targetAngle, velocity.x, snapLag);
currentDistance = Mathf.SmoothDamp(currentDistance, distance, velocity.z, snapLag);

var newPosition = targetCenter;
newPosition += Quaternion.Euler(0, currentAngle, 0) * Vector3.back * currentDistance;

newPosition.y = Mathf.SmoothDamp (position.y, targetCenter.y + height, velocity.y, smoothLag, maxSpeed);

newPosition = AdjustLineOfSight(newPosition, targetCenter);

transform.position = newPosition;

// We are close to the target, so we can stop snapping now!
if (AngleDistance (currentAngle, targetAngle) < 3.0)
{
isSnapping = false;
velocity = Vector3.zero;
}
}

function AdjustLineOfSight (newPosition : Vector3, target : Vector3)
{
var hit : RaycastHit;
if (Physics.Linecast (target, newPosition, hit, lineOfSightMask.value))
{
velocity = Vector3.zero;
return hit.point;
}
return newPosition;
}

function ApplyPositionDamping (targetCenter : Vector3)
{
// We try to maintain a constant distance on the x-z plane with a spring.
// Y position is handled with a seperate spring
var position = transform.position;
var offset = position - targetCenter;
offset.y = 0;
var newTargetPos = offset.normalized * distance + targetCenter;

var newPosition : Vector3;
newPosition.x = Mathf.SmoothDamp (position.x, newTargetPos.x, velocity.x, smoothLag, maxSpeed);
newPosition.z = Mathf.SmoothDamp (position.z, newTargetPos.z, velocity.z, smoothLag, maxSpeed);
newPosition.y = Mathf.SmoothDamp (position.y, targetCenter.y, velocity.y, smoothLag, maxSpeed);

newPosition = AdjustLineOfSight(newPosition, targetCenter);

transform.position = newPosition;
}

function SetUpRotation (centerPos : Vector3, headPos : Vector3)
{
// Now it's getting hairy. The devil is in the details here, the big issue is jumping of course.
// * When jumping up and down don't center the guy in screen space. This is important to give a feel for how high you jump.
// When keeping him centered, it is hard to see the jump.
// * At the same time we dont want him to ever go out of screen and we want all rotations to be totally smooth
//
// So here is what we will do:
//
// 1. We first find the rotation around the y axis. Thus he is always centered on the y-axis
// 2. When grounded we make him be cented
// 3. When jumping we keep the camera rotation but rotate the camera to get him back into view if his head is above some threshold
// 4. When landing we must smoothly interpolate towards centering him on screen
var cameraPos = transform.position;
var offsetToCenter = centerPos - cameraPos;

// Generate base rotation only around y-axis
var yRotation = Quaternion.LookRotation(Vector3(offsetToCenter.x, 0, offsetToCenter.z));

var relativeOffset = Vector3.forward * distance + Vector3.down * height;
transform.rotation = yRotation * Quaternion.LookRotation(relativeOffset);

// Calculate the projected center position and top position in world space
var centerRay = camera.ViewportPointToRay(Vector3(.5, 0.5, 1));
var topRay = camera.ViewportPointToRay(Vector3(.5, clampHeadPositionScreenSpace, 1));

var centerRayPos = centerRay.GetPoint(distance);
var topRayPos = topRay.GetPoint(distance);

var centerToTopAngle = Vector3.Angle(centerRay.direction, topRay.direction);

var heightToAngle = centerToTopAngle / (centerRayPos.y - topRayPos.y);

var extraLookAngle = heightToAngle * (centerRayPos.y - centerPos.y);
if (extraLookAngle < centerToTopAngle)
{
extraLookAngle = 0;
}
else
{
extraLookAngle = extraLookAngle - centerToTopAngle;
transform.rotation *= Quaternion.Euler(-extraLookAngle, 0, 0);
}
}

function AngleDistance (a : float, b : float)
{
a = Mathf.Repeat(a, 360);
b = Mathf.Repeat(b, 360);

return Mathf.Abs(b - a);
}

@script AddComponentMenu ("Third Person Camera/CameraSegueAvatar")


CONTROLE DO PERSONAGEM (FPS), Está em English, porque esse código foi escrito pela Unity..:

Citação:
private var motor : CharacterMotor;

// Use this for initialization
function Awake () {
motor = GetComponent(CharacterMotor);
}

// Update is called once per frame
function Update () {
// Get the input vector from kayboard or analog stick
var directionVector = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));

if (directionVector != Vector3.zero) {
// Get the length of the directon vector and then normalize it
// Dividing by the length is cheaper than normalizing when we already have the length anyway
var directionLength = directionVector.magnitude;
directionVector = directionVector / directionLength;

// Make sure the length is no bigger than 1
directionLength = Mathf.Min(1, directionLength);

// Make the input vector more sensitive towards the extremes and less sensitive in the middle
// This makes it easier to control slow speeds when using analog sticks
directionLength = directionLength * directionLength;

// Multiply the normalized direction vector by the modified length
directionVector = directionVector * directionLength;
}

// Apply the direction to the CharacterMotor
motor.inputMoveDirection = transform.rotation * directionVector;
motor.inputJump = Input.GetButton("Jump");
}

// Require a character controller to be attached to the same game object
@script RequireComponent (CharacterMotor)
@script AddComponentMenu ("Character/FPS Input Controller")



Qui Jun 28, 2012 6:52 pm Exibir perfil de usuários
leocgamer
Usuário
Usuário


Registrado: 27/06/12
Mensagens: 92

Sergio Sinistro escreveu:
cara qual a configuração do seu pc?

o meu pc é um lixo roda tudo com lag e quando eu falei que roda o crysis eu quis dizer ah... bem... digamos...

roda...

com resolução 800x900 e tudo no low e off!

Meu pc: escreveu:

Processador: Intel Core 2 Quad Q8400 2.66Ghz
Memoria RAM: 4GB (DDR2)
HD: 500GB
Placa de vídeo: Geforce 9500GT 1GB (DDR2)
Sistema operacional: Windows XP SP3


Configurações do Meu PC:

Processador: Pentium Dual-Core 2.0 Ghz E2180
Dual Memory Ram: 3Gb DDR2
Placa de Vídeo: Radeon HD 5450 DDR3
Hard Disk: 500 GB SAMSUNG HD502HJ / 7200 RPM
Motherboard: Asus P5KPL-AM


SÓ ISSO: ALÉM DELE SER INFERIOR AO SEU, EM VÁRIOS REQUISITOS, EU RODO CRYSIS 1 E 2, EM 1024X768 NO MEDIUM QUE PARA MIM JÁ É O SUFICIENTE.. QUERIA MAIS, MAS NÃO TÔ COM GRANA PARA DAR UM UPGRADE, RSRS, valeu!
Qui Jun 28, 2012 7:04 pm Exibir perfil de usuários
Alisson124578
Usuário
Usuário


Registrado: 11/03/12
Mensagens: 551

Re: Câmera, Controle do Personagem (FPS), Javascript (Unity)
leocgamer escreveu:
Sim "Sérgio Sinistro", para movimentar o personagem é tudo isso que você disse, porém não é difícil, o negócio é ter paciência e saber programar, em Javascript (UNITY), Csharp ou Boo, você que escolhe o tipo de linguagem que você vai usar. Exemplos de código.:

CÂMERA SEGUE PERSONAGEM:

Citação:
//Esse script foi criado pela Unity Technologies com o nome "SpringFollowCamera" e incluido em demo gratuita.
//Deve ser "grudado" na MainCamera e, o avatar deve ser arrastado para a veriável Target, no Inspector.
//As variáveis Distance e Height devem ser definidas melhor. 10 e 3 são um palpite.Testar.
//Usar com ControladorDoAvatar.js

// This camera is similar to the one used in Jak & Dexter

var target : Transform;
var distance = 4.0;
var height = 1.0;
var smoothLag = 0.2;
var maxSpeed = 10.0;
var snapLag = 0.3;
var clampHeadPositionScreenSpace = 0.75;
var lineOfSightMask : LayerMask = 0;

private var isSnapping = false;
private var headOffset = Vector3.zero;
private var centerOffset = Vector3.zero;
private var controller : ControladorDoAvatar;
private var velocity = Vector3.zero;
private var targetHeight = 100000.0;

function Awake ()
{
var characterController : CharacterController = target.collider;
if (characterController)
{
centerOffset = characterController.bounds.center - target.position;
headOffset = centerOffset;
headOffset.y = characterController.bounds.max.y - target.position.y;
}

if (target)
{
controller = target.GetComponent(ControladorDoAvatar);
}

if (!controller)
Debug.Log("Please assign a target to the camera that has a Third Person Controller script component.");
}

function LateUpdate () {

var targetCenter = target.position + centerOffset;
var targetHead = target.position + headOffset;

// When jumping don't move camera upwards but only down!
if (controller.IsJumping ())
{
// We'd be moving the camera upwards, do that only if it's really high
var newTargetHeight = targetCenter.y + height;
if (newTargetHeight < targetHeight || newTargetHeight - targetHeight > 5)
targetHeight = targetCenter.y + height;
}
// When walking always update the target height
else
{
targetHeight = targetCenter.y + height;
}

// We start snapping when user pressed Fire2!
if (Input.GetButton("Fire2") && !isSnapping)
{
velocity = Vector3.zero;
isSnapping = true;
}

if (isSnapping)
{
ApplySnapping (targetCenter);
}
else
{
ApplyPositionDamping (Vector3(targetCenter.x, targetHeight, targetCenter.z));
}

SetUpRotation(targetCenter, targetHead);
}

function ApplySnapping (targetCenter : Vector3)
{
var position = transform.position;
var offset = position - targetCenter;
offset.y = 0;
var currentDistance = offset.magnitude;

var targetAngle = target.eulerAngles.y;
var currentAngle = transform.eulerAngles.y;

currentAngle = Mathf.SmoothDampAngle(currentAngle, targetAngle, velocity.x, snapLag);
currentDistance = Mathf.SmoothDamp(currentDistance, distance, velocity.z, snapLag);

var newPosition = targetCenter;
newPosition += Quaternion.Euler(0, currentAngle, 0) * Vector3.back * currentDistance;

newPosition.y = Mathf.SmoothDamp (position.y, targetCenter.y + height, velocity.y, smoothLag, maxSpeed);

newPosition = AdjustLineOfSight(newPosition, targetCenter);

transform.position = newPosition;

// We are close to the target, so we can stop snapping now!
if (AngleDistance (currentAngle, targetAngle) < 3.0)
{
isSnapping = false;
velocity = Vector3.zero;
}
}

function AdjustLineOfSight (newPosition : Vector3, target : Vector3)
{
var hit : RaycastHit;
if (Physics.Linecast (target, newPosition, hit, lineOfSightMask.value))
{
velocity = Vector3.zero;
return hit.point;
}
return newPosition;
}

function ApplyPositionDamping (targetCenter : Vector3)
{
// We try to maintain a constant distance on the x-z plane with a spring.
// Y position is handled with a seperate spring
var position = transform.position;
var offset = position - targetCenter;
offset.y = 0;
var newTargetPos = offset.normalized * distance + targetCenter;

var newPosition : Vector3;
newPosition.x = Mathf.SmoothDamp (position.x, newTargetPos.x, velocity.x, smoothLag, maxSpeed);
newPosition.z = Mathf.SmoothDamp (position.z, newTargetPos.z, velocity.z, smoothLag, maxSpeed);
newPosition.y = Mathf.SmoothDamp (position.y, targetCenter.y, velocity.y, smoothLag, maxSpeed);

newPosition = AdjustLineOfSight(newPosition, targetCenter);

transform.position = newPosition;
}

function SetUpRotation (centerPos : Vector3, headPos : Vector3)
{
// Now it's getting hairy. The devil is in the details here, the big issue is jumping of course.
// * When jumping up and down don't center the guy in screen space. This is important to give a feel for how high you jump.
// When keeping him centered, it is hard to see the jump.
// * At the same time we dont want him to ever go out of screen and we want all rotations to be totally smooth
//
// So here is what we will do:
//
// 1. We first find the rotation around the y axis. Thus he is always centered on the y-axis
// 2. When grounded we make him be cented
// 3. When jumping we keep the camera rotation but rotate the camera to get him back into view if his head is above some threshold
// 4. When landing we must smoothly interpolate towards centering him on screen
var cameraPos = transform.position;
var offsetToCenter = centerPos - cameraPos;

// Generate base rotation only around y-axis
var yRotation = Quaternion.LookRotation(Vector3(offsetToCenter.x, 0, offsetToCenter.z));

var relativeOffset = Vector3.forward * distance + Vector3.down * height;
transform.rotation = yRotation * Quaternion.LookRotation(relativeOffset);

// Calculate the projected center position and top position in world space
var centerRay = camera.ViewportPointToRay(Vector3(.5, 0.5, 1));
var topRay = camera.ViewportPointToRay(Vector3(.5, clampHeadPositionScreenSpace, 1));

var centerRayPos = centerRay.GetPoint(distance);
var topRayPos = topRay.GetPoint(distance);

var centerToTopAngle = Vector3.Angle(centerRay.direction, topRay.direction);

var heightToAngle = centerToTopAngle / (centerRayPos.y - topRayPos.y);

var extraLookAngle = heightToAngle * (centerRayPos.y - centerPos.y);
if (extraLookAngle < centerToTopAngle)
{
extraLookAngle = 0;
}
else
{
extraLookAngle = extraLookAngle - centerToTopAngle;
transform.rotation *= Quaternion.Euler(-extraLookAngle, 0, 0);
}
}

function AngleDistance (a : float, b : float)
{
a = Mathf.Repeat(a, 360);
b = Mathf.Repeat(b, 360);

return Mathf.Abs(b - a);
}

@script AddComponentMenu ("Third Person Camera/CameraSegueAvatar")


CONTROLE DO PERSONAGEM (FPS), Está em English, porque esse código foi escrito pela Unity..:

Citação:
private var motor : CharacterMotor;

// Use this for initialization
function Awake () {
motor = GetComponent(CharacterMotor);
}

// Update is called once per frame
function Update () {
// Get the input vector from kayboard or analog stick
var directionVector = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));

if (directionVector != Vector3.zero) {
// Get the length of the directon vector and then normalize it
// Dividing by the length is cheaper than normalizing when we already have the length anyway
var directionLength = directionVector.magnitude;
directionVector = directionVector / directionLength;

// Make sure the length is no bigger than 1
directionLength = Mathf.Min(1, directionLength);

// Make the input vector more sensitive towards the extremes and less sensitive in the middle
// This makes it easier to control slow speeds when using analog sticks
directionLength = directionLength * directionLength;

// Multiply the normalized direction vector by the modified length
directionVector = directionVector * directionLength;
}

// Apply the direction to the CharacterMotor
motor.inputMoveDirection = transform.rotation * directionVector;
motor.inputJump = Input.GetButton("Jump");
}

// Require a character controller to be attached to the same game object
@script RequireComponent (CharacterMotor)
@script AddComponentMenu ("Character/FPS Input Controller")


Simples
Qui Jun 28, 2012 7:18 pm Exibir perfil de usuários
Sergio Sinistro
Usuário
Usuário


Registrado: 25/03/12
Mensagens: 263
Localização: Amazonas

mais quantos fps?

pra mim 30 fps é lag
Qui Jun 28, 2012 7:25 pm Exibir perfil de usuários
leocgamer
Usuário
Usuário


Registrado: 27/06/12
Mensagens: 92

Sergio Sinistro escreveu:
mais quantos fps?

pra mim 30 fps é lag


Essa Média! mesmo, rsrs mas não dá LAG! não
Qui Jun 28, 2012 9:41 pm Exibir perfil de usuários
leocgamer
Usuário
Usuário


Registrado: 27/06/12
Mensagens: 92

Re: Câmera, Controle do Personagem (FPS), Javascript (Unity)
Alisson124578 << ACHOU "SIMPLES"... rsrs
Qui Jun 28, 2012 9:42 pm Exibir perfil de usuários
Alisson124578
Usuário
Usuário


Registrado: 11/03/12
Mensagens: 551

Re: Câmera, Controle do Personagem (FPS), Javascript (Unity)
leocgamer escreveu:
Alisson124578 << ACHOU "SIMPLES"... rsrs


É a real velho


Qui Jun 28, 2012 9:43 pm Exibir perfil de usuários
   3D Game Builder - Índice » Geral Ir à página Anterior  1, 2, 3, 4  Próximo
Página 3 de 4