Skip to content

Instantly share code, notes, and snippets.

@LeviVisser
LeviVisser / gist:834268e5577042ce87578b5c21e42bc3
Created November 20, 2017 18:06
HTC VIVE controller script
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class WandController : MonoBehaviour
{
private Valve.VR.EVRButtonId gripButton = Valve.VR.EVRButtonId.k_EButton_Grip;
private Valve.VR.EVRButtonId triggerButton = Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger;
private SteamVR_Controller.Device controller { get { return SteamVR_Controller.Input((int)trackedObj.index); } }
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class InteractibleItem : MonoBehaviour
{
public Rigidbody Rigidbody;
public BoxCollider collider;
private bool currentlyInteracting;
public WandController attachedHand;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Engine : MonoBehaviour {
[Range(100f, 1000f)]
public float Force;
[Range(10f, 20f)]
public float MaxSpeed;
public bool IsOn;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/**
* A ship contains a weapon system
* This system monitors all the available weapons on the ship and can turn them on or off
* */
public class WeaponSystem : MonoBehaviour {
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Weapon : WeaponSystem {
/**
* Fobject stands for "Firing object"
* This can be a projectile like a laser and missile
* Or an other generic "non projectile" object like an EMP
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Projectile : MonoBehaviour, IDamageDealer<float> {
public float speed;
public float range = 100;
private Vector3 startPosition;
@LeviVisser
LeviVisser / Tank.cpp
Created November 20, 2017 18:34
Tank.cpp
#include "Tank.h"
#include "Engine.h"
// Sets default values
ATank::ATank()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
}
@LeviVisser
LeviVisser / TankAIControler.cpp
Created November 20, 2017 18:35
TankAIControler.cpp
#include "TankAIController.h"
#include "Engine.h" // TODO Find correct include included to fix error given at GetWord()
#include "BattleTank.h"
#include "TankAimingComponent.h"
#include "Tank.h"
void ATankAIController::BeginPlay()
{
Super::BeginPlay();
}
@LeviVisser
LeviVisser / TankAimingComponent.cpp
Created November 20, 2017 18:36
TankAimingComponent.cpp
#include "TankAimingComponent.h"
#include "Engine/World.h"
#include "TankBarrel.h"
#include "TankTurret.h"
#include "Engine.h" // TODO find correct include -> included to solve error UGameplayStatics::SuggestProjectileVelocity
#include "Engine/StaticMesh.h"
// Sets default values for this component's properties
UTankAimingComponent::UTankAimingComponent()
{
using UnityEngine;
public class ShipMovementComponent : MonoBehaviour {
private Vector3 cameraStartingPos;
private Vector3 crosshairScreenPos;
private Vector3 crosshairViewPos;
private Vector3 crosshairWorldPos;
private float maxHorizontalCamChange;
private float MaxRotationRoll = 70;