- Home /
How to get my script to work with Ultimate FPS camera
Hi guys, so Ive made a script which lets you break and place blocks (with varying speeds, theres also a shovel which increases the speed) and it works fine, but Ive brought the ultimate fps camera, and was wondering if there was a way I could get it to work with it, perhaps by switching modes (1 mode takes you to the ultimate fps, the other to this script). Also, my terrain isnt made of the blocks, so I also need help making the script only be able to break blocks Ive placed. many thanks
//Misc
var BlockSelected : float = 1;
var Range : float = 20;
var Crosshair : Texture2D;
//Shovel (0)
var WoodShovel : GameObject;
var WoodShovelDestroyTime : float = 0.5;
//Grass (1)
var GrassBlock : Transform;
var HeldGrassBlock : GameObject;
var GrassBlockDestroyTime : float = 1;
//Stone (2)
var StoneBlock : Transform;
function Update ()
{
// changing items
if (Input.GetKeyDown(KeyCode.Q))
{
BlockSelected -= 1;
}
if (Input.GetKeyDown(KeyCode.E))
{
BlockSelected += 1;
}
if (BlockSelected == 0)
{
WoodShovel.active = true;
}
else WoodShovel.active = false;
if (BlockSelected == 1)
{
HeldGrassBlock.active = true;
}
else HeldGrassBlock.active = false;
//adding and deleting blocks
if (Input.GetMouseButtonDown(0 && WoodShovel.ShovelSelected == true) || Input.GetMouseButtonDown(1))
{
var Hit : RaycastHit;
var LookingDirection = transform.TransformDirection(Vector3.forward);
if (Physics.Raycast(transform.position, LookingDirection, Hit, 20))
{
if (Input.GetMouseButtonDown(1))
{
if (BlockSelected ==1)
{
var GrassBlock :Transform = Instantiate(GrassBlock, Hit.collider.transform.position + Hit.normal.normalized, Quaternion.identity);
GrassBlock.tag = "GrassBlock";
}
if (BlockSelected == 2)
{
var StoneBlock :Transform = Instantiate(StoneBlock, Hit.collider.transform.position + Hit.normal.normalized, Quaternion.identity);
GrassBlock.tag = "StoneBlock";
}
}
else
{
if (BlockSelected == 0)
{
Destroy(Hit.transform.gameObject, WoodShovelDestroyTime);
}
if (BlockSelected == 1)
{
Destroy(Hit.transform.gameObject, GrassBlockDestroyTime);
}
if (BlockSelected == 2)
{
Destroy(Hit.transform.gameObject, 4);
}
}
}
}
}
function OnGUI()
{
var Width = Crosshair.width/2;
var Height = Crosshair.height/2;
position = Rect( (Screen.width - Width)/2, (Screen.height - Height)/2, Width, Height);
GUI.DrawTexture(position, Crosshair);
}
Your answer
Follow this Question
Related Questions
Import camera that follows a path from 3dsmax 4 Answers
How to display text with the GUI Text object when using the Ultimate FPS Camera Asset 0 Answers
Voluemtric cloud works good in edit mode but doesn't appear after game built 0 Answers
point light not emitting? 0 Answers
How do I change FOV for the starter assets camera? 0 Answers