I have a normal character ,and i have a attached a character control`s move script ,and also i have attached the smooth follow script of the camera to the main camera…there are no errors but the character is not moving,and also if i put the gravity to 20 its goes inside the plane as if a plane is a liquid not a solid…(I am a beginner)…m stuck with not knowing what to do…need some suggestions here…
2 Answers
2u need 2 show some code .How u want the character to move ? when u press a key? show some codes
yeah m learning from the unity tutorials itself these 2 scripts i have tried for the game object …
using UnityEngine;
using System.Collections;
public class movementnewcode : MonoBehaviour {
void FixedUpdate(){
float movementhorizontal= Input.GetAxis("Horizontal");
float movementvertical=Input.GetAxis("Vertical");
Vector3 movement =new Vector3(movementhorizontal,0.0f, movementvertical);
rigidbody.AddForce(movement);
}
}
and this is the other built in script provided in the unity scripts…
var speed : float = 6.0;
var jumpSpeed : float = 8.0;
var gravity : float = 20.0;
private var moveDirection : Vector3 = Vector3.zero;
function Update() {
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded) {
// We are grounded, so recalculate
// move direction directly from axes
moveDirection = Vector3(Input.GetAxis(“Horizontal”), 0,
Input.GetAxis(“Vertical”));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
if (Input.GetButton ("Jump")) {
moveDirection.y = jumpSpeed;
}
}
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
// Move the controller
controller.Move(moveDirection * Time.deltaTime);
}
The object is moving now ,, but the gravity problem is not yet resolved...whenever I check the checkbox for the gravity in the rigid body component...the game object starts to move inside the plane...I mean i want the plane to act as a floor and not water..so I guess I am making some serious mistakes here...I appreciate your help ...thank you..
– beernsnow